#147 open

link#absolute_href is broken

Reported by dstar | January 26th, 2009 @ 02:25 PM | in 0.4.2

There is a bug in link#absolute_href:

54 def absolute_href 55 if href =~ /^\?/ 56 "#{@session.current_url}#{href}" 57 elsif href !~ %r{^https?://www.example.com(/.*)} && (href !~ /^\//) 58 "#{@session.current_url}/#{href}" 59 else 60 href 61 end 62 end

I'm not positive, but I think Line 55 should be:

if href =~ /^\/?/

unless it's meant to be checking for urls that begin with '?'? If so, it would turn ?foo into 'http://foo.bar.baz?foo', which I'm not sure is legal.

Line 57 should not check for the existence of www.example.com, as that causes it to fail on absolute urls. Assuming that I'm right about line 55, it should also not check that href is a relative url, as it can never be reached if it is:
elsif href !~ %r{^https?://[^/]+(/.*)}

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket