add tests which prove the current behavior of not decoding chained args but decoding...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Regex.pm
index 0b6f97c..354fe33 100644 (file)
@@ -148,13 +148,15 @@ sub uri_for_action {
             $re =~ s/^\^//;
             $re =~ s/\$$//;
             my $final = '/';
-            my @captures = @$captures;
+            my @captures =  map { s/([^A-Za-z0-9\-_.!~*'()])/$URI::Escape::escapes{$1}/go; $_; } @$captures;
             while (my ($front, $rest) = split(/\(/, $re, 2)) {
+                last unless defined $rest;
                 ($rest, $re) =
                     Text::Balanced::extract_bracketed("(${rest}", '(');
                 next REGEX unless @captures;
                 $final .= $front.shift(@captures);
             }
+            $final .= $re;
             next REGEX if @captures;
             return $final;
          }