do something rational in the case where you call $app->uri_for
John Napiorkowski [Mon, 25 Mar 2013 14:39:43 +0000 (10:39 -0400)]
lib/Catalyst.pm

index 43bda89..c2e925b 100644 (file)
@@ -1341,10 +1341,14 @@ sub uri_for {
     # join args with '/', or a blank string
     my $args = join('/', grep { defined($_) } @args);
     $args =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE
-    $args =~ s!^/+!!;
-    my $base = $c->req->base;
-    my $class = ref($base);
-    $base =~ s{(?<!/)$}{/};
+    $args =~ s!^/+!!i;
+
+    my ($base, $class) = ('/', 'URI::_generic');
+    if(blessed($c)) {
+      $base = $c->req->base;
+      $class = ref($base);
+      $base =~ s{(?<!/)$}{/};
+    }
 
     my $query = '';