Removes potential spaces in robots.txt entries - Ref #819

This commit is contained in:
erwanlr
2015-05-08 09:50:51 +01:00
parent b22550ea55
commit b5d5c4177d
3 changed files with 6 additions and 4 deletions

View File

@@ -15,7 +15,6 @@ class WebSite
@uri.clone.merge('robots.txt').to_s @uri.clone.merge('robots.txt').to_s
end end
# Parse robots.txt # Parse robots.txt
# @return [ Array ] URLs generated from robots.txt # @return [ Array ] URLs generated from robots.txt
def parse_robots_txt def parse_robots_txt
@@ -40,9 +39,9 @@ class WebSite
entries.each do |d| entries.each do |d|
begin begin
temp = @uri.clone temp = @uri.clone
temp.path = d temp.path = d.strip
rescue URI::Error rescue URI::Error
temp = d temp = d.strip
end end
return_object << temp.to_s return_object << temp.to_s
end end

View File

@@ -5,6 +5,7 @@ Disallow: /wordpress/admin/
Disallow: /wordpress/wp-admin/ Disallow: /wordpress/wp-admin/
Disallow: /wordpress/secret/ Disallow: /wordpress/secret/
Disallow: /Wordpress/wp-admin/ Disallow: /Wordpress/wp-admin/
Disallow: /wp-admin/tralling-space/
Allow: /asdf/ Allow: /asdf/
Sitemap: http://10.0.0.0/sitemap.xml.gz Sitemap: http://10.0.0.0/sitemap.xml.gz

View File

@@ -5,7 +5,7 @@ shared_examples 'WebSite::RobotsTxt' do
describe '#robots_url' do describe '#robots_url' do
it 'returns the correct url' do it 'returns the correct url' do
expect(web_site.robots_url).to be === 'http://example.localhost/robots.txt' expect(web_site.robots_url).to eql 'http://example.localhost/robots.txt'
end end
end end
@@ -57,6 +57,7 @@ shared_examples 'WebSite::RobotsTxt' do
http://example.localhost/wordpress/wp-admin/ http://example.localhost/wordpress/wp-admin/
http://example.localhost/wordpress/secret/ http://example.localhost/wordpress/secret/
http://example.localhost/Wordpress/wp-admin/ http://example.localhost/Wordpress/wp-admin/
http://example.localhost/wp-admin/tralling-space/
http://example.localhost/asdf/ http://example.localhost/asdf/
) )
end end
@@ -70,6 +71,7 @@ shared_examples 'WebSite::RobotsTxt' do
http://example.localhost/wordpress/admin/ http://example.localhost/wordpress/admin/
http://example.localhost/wordpress/secret/ http://example.localhost/wordpress/secret/
http://example.localhost/Wordpress/wp-admin/ http://example.localhost/Wordpress/wp-admin/
http://example.localhost/wp-admin/tralling-space/
http://example.localhost/asdf/ http://example.localhost/asdf/
) )
stub_request_to_fixture(url: web_site_sub.robots_url, fixture: fixture) stub_request_to_fixture(url: web_site_sub.robots_url, fixture: fixture)