///|
test "rfc example allow private public" {
let f = unwrap_file(
parse_robots("User-agent: foobot\nDisallow: /\nAllow: /example/page.html\n"),
)
assert_true(can_fetch(f, "FooBot", "/example/page.html"))
assert_false(can_fetch(f, "FooBot", "/example/elsewhere.html"))
}
///|
test "rfc example longest match with wildcard" {
let f = unwrap_file(
parse_robots("User-agent: *\nAllow: /fish*.php\nDisallow: /fish\n"),
)
assert_true(can_fetch(f, "bot", "/fishheads/catfish.php"))
}
///|
test "rfc example dollar terminator" {
let f = unwrap_file(parse_robots("User-agent: *\nDisallow: /fish$\n"))
assert_false(can_fetch(f, "bot", "/fish"))
assert_true(can_fetch(f, "bot", "/fish.html"))
}
///|
test "rfc example percent encoded unreserved equivalence" {
let f = unwrap_file(parse_robots("User-agent: *\nDisallow: /foo/bar\n"))
assert_false(can_fetch(f, "bot", "/foo/%62ar"))
}
///|
test "rfc example reserved slash not decoded" {
let f = unwrap_file(parse_robots("User-agent: *\nDisallow: /foo/bar\n"))
assert_true(can_fetch(f, "bot", "/foo%2Fbar"))
}
///|
test "rfc example raw UTF-8 and percent encoded path are equivalent" {
let f = unwrap_file(parse_robots("User-agent: *\nDisallow: /foo/bar/ツ\n"))
assert_false(can_fetch(f, "bot", "/foo/bar/%E3%83%84"))
}