[Catalyst-commits] r10981 - in
trunk/Catalyst-Plugin-Session-State-URI:
lib/Catalyst/Plugin/Session/State t
autarch at dev.catalyst.perl.org
autarch at dev.catalyst.perl.org
Sun Jul 26 00:24:59 GMT 2009
Author: autarch
Date: 2009-07-26 00:24:59 +0000 (Sun, 26 Jul 2009)
New Revision: 10981
Modified:
trunk/Catalyst-Plugin-Session-State-URI/lib/Catalyst/Plugin/Session/State/URI.pm
trunk/Catalyst-Plugin-Session-State-URI/t/basic.t
Log:
Make sure we don't end up with doubled slashes in a rewritten URI
Modified: trunk/Catalyst-Plugin-Session-State-URI/lib/Catalyst/Plugin/Session/State/URI.pm
===================================================================
--- trunk/Catalyst-Plugin-Session-State-URI/lib/Catalyst/Plugin/Session/State/URI.pm 2009-07-25 21:05:19 UTC (rev 10980)
+++ trunk/Catalyst-Plugin-Session-State-URI/lib/Catalyst/Plugin/Session/State/URI.pm 2009-07-26 00:24:59 UTC (rev 10981)
@@ -264,8 +264,10 @@
sub uri_with_path_sessionid {
my ( $c, $uri_obj, $sid ) = @_;
- $uri_obj->path( join( "/-/", $uri_obj->path, $sid ) );
+ ( my $old_path = $uri_obj->path ) =~ s{/$}{};
+ $uri_obj->path( join( "/-/", $old_path, $sid ) );
+
return $uri_obj;
}
Modified: trunk/Catalyst-Plugin-Session-State-URI/t/basic.t
===================================================================
--- trunk/Catalyst-Plugin-Session-State-URI/t/basic.t 2009-07-25 21:05:19 UTC (rev 10980)
+++ trunk/Catalyst-Plugin-Session-State-URI/t/basic.t 2009-07-26 00:24:59 UTC (rev 10981)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 51;
+use Test::More tests => 53;
use Test::MockObject::Extends;
use URI;
@@ -50,13 +50,20 @@
can_ok( $m, "session_should_rewrite" );
ok( $cxt->session_should_rewrite, "sessions should rewrite by default" );
-foreach my $uri (qw{ any http://string/in http://the/world/ }) {
+foreach my $uri (qw{ any http://string/in http://the/world }) {
$sessionid = "foo";
can_ok( $m, "uri_with_sessionid" );
is( $cxt->uri_with_sessionid($uri), "${uri}/-/foo" );
$sessionid = undef;
}
+{
+ $sessionid = 'bar';
+ is( $cxt->uri_with_sessionid( q{/} ), "/-/bar" );
+ is( $cxt->uri_with_sessionid( q{/trailing/slash/} ), "/trailing/slash/-/bar" );
+ $sessionid = undef;
+}
+
can_ok( $m, "session_should_rewrite_uri" );
ok(
More information about the Catalyst-commits
mailing list