From: Tomas Doran Date: Sun, 7 Dec 2008 18:31:30 +0000 (+0000) Subject: Test and fix for a case which caused uri_for to generate a double slash at the start... X-Git-Tag: 5.8000_05~107 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7a2295bc5e5acd73fe7ffc3bc556dfa2ec74486a Test and fix for a case which caused uri_for to generate a double slash at the start of paths --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 8cb6866..63c2fb7 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1077,7 +1077,7 @@ sub uri_for { # join args with '/', or a blank string my $args = join('/', grep { defined($_) } @args); $args =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE - $args =~ s!^/!!; + $args =~ s!^/+!!; my $base = $c->req->base; my $class = ref($base); $base =~ s{(? 15; +use Test::More tests => 16; use URI; use_ok('Catalyst'); @@ -103,3 +103,8 @@ is( is( $warnings, 0, "no warnings emitted" ); } +# Test with parameters '/', 'foo', 'bar' - should not generate a // +is( Catalyst::uri_for( $context, qw| / foo bar | )->as_string, + 'http://127.0.0.1/foo/bar', 'uri is /foo/bar, not //foo/bar' +); +