From: Andy Grundman Date: Thu, 3 Nov 2005 16:25:01 +0000 (+0000) Subject: Fixed req->{path} for backwards-compat X-Git-Tag: 5.7099_04~1036 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=e561386ff49b0b44ad131d72b807c076825bcdb3 Fixed req->{path} for backwards-compat --- diff --git a/Changes b/Changes index 833dc14..66b09b2 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Tis file documents the revision history for Perl extension Catalyst. 5.50 + - Fixed $c->req->{path} for backwards-compatibility. - Allow debug to be disabled via ENV as well as enabled. - Added -scripts option to catalyst.pl for script updating - Changed helpers to default to long types, Controller instead of C diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index b38b693..117902e 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -6,7 +6,7 @@ use base 'Class::Accessor::Fast'; use IO::Socket qw[AF_INET inet_aton]; __PACKAGE__->mk_accessors( - qw/action address arguments base cookies headers match method + qw/action address arguments cookies headers match method protocol query_parameters secure snippets uri user/ ); @@ -105,6 +105,23 @@ Returns a reference to an array containing the arguments. Contains the url base. This will always have a trailing slash. +=cut + +sub base { + my ( $self, $base ) = @_; + + return $self->{base} unless $base; + + $self->{base} = $base; + + # set the value in path for backwards-compat + if ( $self->uri ) { + $self->path; + } + + return $self->{base}; +} + =item $req->body Contains the message body of the request unless Content-Type is @@ -333,12 +350,16 @@ sub path { if ($params) { $self->uri->path($params); } + else { + return $self->{path} if $self->{path}; + } my $path = $self->uri->path; my $location = $self->base->path; $path =~ s/^(\Q$location\E)?//; $path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; $path =~ s/^\///; + $self->{path} = $path; return $path; }