Skip to content

Commit 237d89e

Browse files
author
Martin Skovvang Petersen
committed
Always allow /robots.txt
1 parent a800196 commit 237d89e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

robotstxtparser/robotstxtparser.py

+3
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ def is_url_allowed(self, url, syntax=GYM2008):
251251

252252
url = _unquote_path(url)
253253

254+
if url == '/robots.txt':
255+
return True
256+
254257
done = False
255258
i = 0
256259
while not done:

tests/test_robots.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_rfc_example(self):
114114
# The unhipbot bot
115115
self.assertFalse(rp.is_allowed('unhipbot', 'http://example.org/'))
116116
self.assertFalse(rp.is_allowed('unhipbot', 'http://example.org/index.html'))
117-
#self.assertTrue(rp.is_allowed('unhipbot', 'http://example.org/robots.txt')) TODO
117+
self.assertTrue(rp.is_allowed('unhipbot', 'http://example.org/robots.txt'))
118118
self.assertFalse(rp.is_allowed('unhipbot', 'http://example.org/server.html'))
119119
self.assertFalse(rp.is_allowed('unhipbot', 'http://example.org/services/fast.html'))
120120
self.assertFalse(rp.is_allowed('unhipbot', 'http://example.org/services/slow.html'))
@@ -153,7 +153,7 @@ def test_rfc_example(self):
153153
# All others
154154
self.assertFalse(rp.is_allowed('anything', 'http://example.org/'))
155155
self.assertFalse(rp.is_allowed('anything', 'http://example.org/index.html'))
156-
#self.assertTrue(rp.is_allowed('anything', 'http://example.org/robots.txt')) TODO
156+
self.assertTrue(rp.is_allowed('anything', 'http://example.org/robots.txt'))
157157
self.assertTrue(rp.is_allowed('anything', 'http://example.org/server.html'))
158158
self.assertTrue(rp.is_allowed('anything', 'http://example.org/services/fast.html'))
159159
self.assertTrue(rp.is_allowed('anything', 'http://example.org/services/slow.html'))

0 commit comments

Comments
 (0)