support hashref for params in uri_for
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index b30ecf1..d93707f 100644 (file)
@@ -47,7 +47,7 @@ our $DETACH    = "catalyst_detach\n";
 require Module::Pluggable::Fast;
 
 # Helper script generation
-our $CATALYST_SCRIPT_GEN = 26;
+our $CATALYST_SCRIPT_GEN = 27;
 
 __PACKAGE__->mk_classdata($_)
   for qw/components arguments dispatcher engine log dispatcher_class
@@ -717,12 +717,15 @@ sub uri_for {
     $namespace = '' if $path =~ /^\//;
     $path =~ s/^\///;
 
+    my $params = (scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {});
+
     # join args with '/', or a blank string
     my $args = ( scalar @args ? '/' . join( '/', @args ) : '' );
     $args =~ s/^\/// unless $path;
     my $res =
       URI->new_abs( URI->new_abs( "$path$args", "$basepath$namespace" ), $base )
       ->canonical;
+    $res->query_form(%$params);
     $res;
 }