Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/prefix wildcard with fullpath #38

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add failing test
  • Loading branch information
tuxnco committed Mar 14, 2019
commit 066cf971457e1e635084ee5ba20e55625762e5df
18 changes: 18 additions & 0 deletions test/test-robots.cpp
Original file line number Diff line number Diff line change
@@ -319,3 +319,21 @@ TEST(RobotsTest, NeverExternalAllowed)
Rep::Robots robot("", "http://a.com/robots.txt");
EXPECT_FALSE(robot.allowed("http://b.com/", "one"));
}

TEST(RobotsTest, PrefixStarExample)
{
std::string content =
"# /robots.txt for fun and profit\n"
"\n"
"User-agent: ohmagad\n"
"Allow: /\n"
"Disallow: */dir\n"
"Disallow: /*/dir\n";
Rep::Robots robot(content);

// The ohmagad bot
EXPECT_TRUE(robot.allowed("/", "ohmagad"));
EXPECT_TRUE(robot.allowed("/a/b/page.html", "ohmagad"));
EXPECT_FALSE(robot.allowed("/dir/page.html", "ohmagad"));
EXPECT_FALSE(robot.allowed("/some/dir/page.html", "ohmagad"));
}