http://www.perlmonks.org?node_id=900739


in reply to Re: Relative URI
in thread Relative URI

He expects http://a.b.c/d/../e/ to be the same as http://a.b.c/e/.

use strict; use warnings; use Test::More tests => 1; use URI qw( ); my $base1 = URI->new("http://a.b.c/d/../e/"); my $base2 = URI->new_abs("../e/", URI->new("http://a.b.c/d/")); my $uri = URI->new("http://a.b.c/y"); is($uri->rel($base1), $uri->rel($base2)); 1;
1..1 not ok 1 # Failed test at a.pl line 12. # got: '../../../y' # expected: '../y' # Looks like you failed 1 test of 1.

I don't see anything in http://cpansearch.perl.org/src/GAAS/URI-1.58/t/abs.t that covers this case.

The equality definitely doesn't hold up in file systems (due to links both soft and hard), but ../../../y is much less likely to be correct.

Update: Improved test a bit.