Unfuck
Tomas Doran [Mon, 8 Feb 2010 21:20:05 +0000 (21:20 +0000)]
lib/Catalyst.pm

index 495a715..4dd08e4 100644 (file)
@@ -1265,6 +1265,9 @@ sub uri_for {
       ( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} );
 
     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;
@@ -1293,17 +1296,6 @@ sub uri_for {
 
     undef($path) if (defined $path && $path eq '');
 
-    my $params =
-      ( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} );
-
-    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;
-    s|/|%2F| for @args;
-
     unshift(@args, $path);
 
     unless (defined $path && $path =~ s!^/!!) { # in-place strip