From: Wallace Reis Date: Thu, 6 May 2010 12:34:10 +0000 (+0000) Subject: make uri_for a bit cleaner X-Git-Tag: 5.80023~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=49229f681a8c73aed828f2589d4eea82481e5e6f make uri_for a bit cleaner --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 42dabb8..2c1b768 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1280,13 +1280,11 @@ sub uri_for { carp "uri_for called with undef argument" if grep { ! defined $_ } @args; foreach my $arg (@args) { utf8::encode($arg) if utf8::is_utf8($arg); - } - s/([^$URI::uric])/$URI::Escape::escapes{$1}/go for @args; - if (blessed $path) { # Action object only. - s|/|%2F|g for @args; + $arg =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go; } if ( blessed($path) ) { # action object + s|/|%2F|g for @args; my $captures = [ map { s|/|%2F|g; $_; } ( scalar @args && ref $args[0] eq 'ARRAY' ? @{ shift(@args) } @@ -1307,8 +1305,6 @@ sub uri_for { $path = '/' if $path eq ''; } - undef($path) if (defined $path && $path eq ''); - unshift(@args, $path); unless (defined $path && $path =~ s!^/!!) { # in-place strip