From: Sebastian Riedel Date: Mon, 14 Nov 2005 00:10:30 +0000 (+0000) Subject: Changed uri_for behavior, updated for 5.51 X-Git-Tag: 5.7099_04~928 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ccc9f8aa38cae2603b7111400ed6de24cdfcb419 Changed uri_for behavior, updated for 5.51 --- diff --git a/Changes b/Changes index e2ac51a..874883c 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,12 @@ Tis file documents the revision history for Perl extension Catalyst. +5.51 2005-11-14 00:45:00 + - Changed uri_for to use namespace instead of match + +5.5 2005-11-13 20:45:00 + - Fixed minor bugs + - Updated docs + 5.49_05 2005-11-12 20:45:00 - Large update to the documentation. (David Kamholz) - Fixed args handling in forward() diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 15b3ea3..23ad038 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -54,7 +54,7 @@ __PACKAGE__->engine_class('Catalyst::Engine::CGI'); __PACKAGE__->request_class('Catalyst::Request'); __PACKAGE__->response_class('Catalyst::Response'); -our $VERSION = '5.5'; +our $VERSION = '5.51'; sub import { my ( $class, @arguments ) = @_; @@ -667,7 +667,7 @@ EOF =item $c->uri_for( $path, [ @args ] ) Merges path with C<$c-Erequest-Ebase> for absolute uri's and -with C<$c-Erequest-Ematch> for relative uri's, then returns a +with C<$c-Enamespace> for relative uri's, then returns a normalized L object. If any args are passed, they are added at the end of the path. @@ -679,18 +679,18 @@ sub uri_for { my $basepath = $base->path; $basepath =~ s/\/$//; $basepath .= '/'; - my $match = $c->request->match; + my $namespace = $c->namespace; - # massage match, empty if absolute path - $match =~ s/^\///; - $match .= '/' if $match; + # massage namespace, empty if absolute path + $namespace =~ s/^\///; + $namespace .= '/' if $namespace; $path ||= ''; - $match = '' if $path =~ /^\//; + $namespace = '' if $path =~ /^\//; $path =~ s/^\///; # join args with '/', or a blank string my $args = ( scalar @args ? '/' . join( '/', @args ) : '' ); - return URI->new_abs( URI->new_abs( "$path$args", "$basepath$match" ), + return URI->new_abs( URI->new_abs( "$path$args", "$basepath$namespace" ), $base )->canonical; } diff --git a/t/unit/core/uri_for.t b/t/unit/core/uri_for.t index 81324b7..4b02021 100644 --- a/t/unit/core/uri_for.t +++ b/t/unit/core/uri_for.t @@ -6,11 +6,11 @@ use Test::MockObject; use URI; my $request = Test::MockObject->new; -$request->mock( 'base', sub { URI->new('http://127.0.0.1/foo') } ); -$request->mock( 'match', sub { '/yada' } ); +$request->mock( 'base', sub { URI->new('http://127.0.0.1/foo') } ); my $context = Test::MockObject->new; -$context->mock( 'request', sub { $request } ); +$context->mock( 'request', sub { $request } ); +$context->mock( 'namespace', sub { 'yada' } ); use_ok('Catalyst'); @@ -38,11 +38,11 @@ is( ); { - $request->mock( 'base', sub { URI->new('http://127.0.0.1/') } ); - $request->mock( 'match', sub { '' } ); + $request->mock( 'base', sub { URI->new('http://127.0.0.1/') } ); my $context = Test::MockObject->new; - $context->mock( 'request', sub { $request } ); + $context->mock( 'request', sub { $request } ); + $context->mock( 'namespace', sub { '' } ); is( Catalyst::uri_for( $context, '/bar/baz' )->as_string, 'http://127.0.0.1/bar/baz', 'URI with no base or match' );