[Catalyst-commits] r6180 - in trunk/Catalyst-Runtime: lib t
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Wed Mar 21 17:09:06 GMT 2007
Author: bricas
Date: 2007-03-21 17:09:06 +0000 (Wed, 21 Mar 2007)
New Revision: 6180
Modified:
trunk/Catalyst-Runtime/lib/Catalyst.pm
trunk/Catalyst-Runtime/t/unit_core_uri_for.t
Log:
Handle "0" as a path
Modified: trunk/Catalyst-Runtime/lib/Catalyst.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst.pm 2007-03-21 07:04:10 UTC (rev 6179)
+++ trunk/Catalyst-Runtime/lib/Catalyst.pm 2007-03-21 17:09:06 UTC (rev 6180)
@@ -932,7 +932,7 @@
# massage namespace, empty if absolute path
$namespace =~ s/^\/// if $namespace;
$namespace .= '/' if $namespace;
- $path ||= '';
+ $path = '' if !defined $path;
$namespace = '' if $path =~ /^\//;
$path =~ s/^\///;
$path =~ s/\?/%3F/g;
@@ -956,7 +956,7 @@
}
s/\?/%3F/g; $_
} @args ) : '' );
- $args =~ s/^\/// unless $path;
+ $args =~ s/^\/// unless length $path;
my $res =
URI->new_abs( URI->new_abs( "$path$args", "$basepath$namespace" ), $base )
->canonical;
Modified: trunk/Catalyst-Runtime/t/unit_core_uri_for.t
===================================================================
--- trunk/Catalyst-Runtime/t/unit_core_uri_for.t 2007-03-21 07:04:10 UTC (rev 6179)
+++ trunk/Catalyst-Runtime/t/unit_core_uri_for.t 2007-03-21 17:09:06 UTC (rev 6180)
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 13;
+use Test::More tests => 14;
use URI;
use_ok('Catalyst');
@@ -81,6 +81,12 @@
is( Catalyst::uri_for( $context, '/bar/baz' )->as_string,
'http://127.0.0.1/bar/baz', 'URI with no base or match' );
+
+ # test "0" as the path
+ is( Catalyst::uri_for( $context, qw/0 foo/ )->as_string,
+ 'http://127.0.0.1/0/foo', '0 as path is ok'
+ );
+
}
# test with undef -- no warnings should be thrown
More information about the Catalyst-commits
mailing list