Fix to allow uri_for and uri_with to stringify non-array references
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Request.pm
index 99035b3..219a7c1 100644 (file)
@@ -500,8 +500,9 @@ Returns a URI object for the current request. Stringifies to the URI text.
 
 =head2 $req->uri_with( { key => 'value' } );
 
-Returns a rewriten URI object for the current uri. Key/value pairs passed in
-will override existing parameters. Unmodified pairs will be preserved.
+Returns a rewritten URI object for the current request. Key/value pairs
+passed in will override existing parameters. Unmodified pairs will be
+preserved.
 
 =cut
 
@@ -509,14 +510,14 @@ sub uri_with {
     my( $self, $args ) = @_;
     
     carp( 'No arguments passed to uri_with()' ) unless $args;
-    
+
     for my $value ( values %$args ) {
-        my $isa_ref = ref $value;
-        if( $isa_ref and $isa_ref ne 'ARRAY' ) {
-            croak( "Non-array reference ($isa_ref) passed to uri_with()" );
+        for ( ref $value eq 'ARRAY' ? @$value : $value ) {
+            $_ = "$_";
+            utf8::encode( $_ );
         }
-        utf8::encode( $_ ) for grep{ defined } $isa_ref ? @$value : $value;
     };
+    
     my $uri = $self->uri->clone;
     
     $uri->query_form( {