diff --git a/lib/webrat/core/link.rb b/lib/webrat/core/link.rb index c7205ad..6d97b02 100644 --- a/lib/webrat/core/link.rb +++ b/lib/webrat/core/link.rb @@ -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 diff --git a/spec/api/click_link_spec.rb b/spec/api/click_link_spec.rb index 2f29248..62b8c82 100644 --- a/spec/api/click_link_spec.rb +++ b/spec/api/click_link_spec.rb @@ -270,6 +270,15 @@ describe "click_link" do end it "should follow fully qualified local links" do + @session.stub!(:current_url).and_return("/page") + @session.response_body = <<-EOS + Jump to sub page + EOS + @session.should_receive(:get).with("http://subdomain.example.com/page/sub", {}) + @session.click_link "Jump to sub page" + end + + it "should follow fully qualified local links to example.com" do @session.response_body = <<-EOS Jump to sub page EOS