empty relative URL's

Andrew Pimlott (pimlott@abel.math.harvard.edu)
Fri, 3 Sep 1999 16:14:41 -0400 (EDT)


URI->new('', 'http')->abs('http://foo/bar.html');

returns http://foo/bar.html .  Is this expected?  The big two browsers 
think it's http://foo/ , but lynx agrees with LWP, which inclines me to 
think LWP is correct.  (Sigh.)  Can someone confirm this?

The LWP fragment responsible (LWP version 5.44) is in URI/_generic.pm, 
around line 141:

    if (!length($path) && $$self !~ /\?/) {
        my $abs = $base->clone;
        $abs->fragment($self->fragment);
        return $abs;
    }   

The check for length($path) catches empty relative URL's, so it certainly 
seems someone explicitly intended this behavior.

You can test your favorite browser by creating a web page containing

<a href="">hi</a>

acessing it as http://foo/whatever.html , and seeing whether the link 
points to http://foo/ or http://foo/whatever.html .

I'm sorry I don't have time to read the URI spec at the moment.

Thanks,
Andrew

(Please cc: me; I'm not on this mailing list.)