From 928222a9876af505c2063cf7e8bf0f762a027f36 Mon Sep 17 00:00:00 2001 From: Masahiro Honma Date: Fri, 27 Jan 2012 16:30:41 +0900 Subject: [PATCH] Respect RFC 1738. We can also omit "/" when and are empty, but it makes t/old-base.t fail. --- URI/http.pm | 3 +-- t/http.t | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/URI/http.pm b/URI/http.pm index cb698224..e3d456c4 100644 --- a/URI/http.pm +++ b/URI/http.pm @@ -12,8 +12,7 @@ sub canonical my $self = shift; my $other = $self->SUPER::canonical; - my $slash_path = defined($other->authority) && - !length($other->path) && !defined($other->query); + my $slash_path = defined($other->authority) && !length($other->path); if ($slash_path) { $other = $other->clone if $other == $self; diff --git a/t/http.t b/t/http.t index 2b8c44bb..dd54ae90 100644 --- a/t/http.t +++ b/t/http.t @@ -1,6 +1,6 @@ #!perl -w -print "1..15\n"; +print "1..16\n"; use URI; @@ -61,3 +61,8 @@ $u = URI->new("http://%77%77%77%2e%70%65%72%6c%2e%63%6f%6d/%70%75%62/%61/%32%30% print "not " unless $u->canonical eq "http://www.perl.com/pub/a/2001/08/27/bjornstad.html"; print "ok 15\n"; +# RFC 1738: "/" can't be ommited when is present. +$u = URI->new("http://localhost?p=1"); +print "not " unless $u->canonical eq "http://localhost/?p=1"; +print "ok 16\n"; +