fix following fully qualified local links

This commit is contained in:
Lawrence Pit 2008-11-05 14:20:47 +11:00
parent 4a898b4223
commit 98d52176ad
2 changed files with 4 additions and 3 deletions

View File

@ -54,7 +54,7 @@ module Webrat
def absolute_href
if href =~ /^\?/
"#{@session.current_url}#{href}"
elsif href !~ %r{^https?://www.example.com(/.*)} && (href !~ /^\//)
elsif href !~ %r{^https?://} && (href !~ /^\//)
"#{@session.current_url}/#{href}"
else
href

View File

@ -270,10 +270,11 @@ describe "clicks_link" do
end
it "should follow fully qualified local links" do
@session.stub!(:current_url).and_return("/page")
@session.response_body = <<-EOS
<a href="http://www.example.com/page/sub">Jump to sub page</a>
<a href="http://subdomain.example.com/page/sub">Jump to sub page</a>
EOS
@session.should_receive(:get).with("http://www.example.com/page/sub", {})
@session.should_receive(:get).with("http://subdomain.example.com/page/sub", {})
@session.clicks_link "Jump to sub page"
end