prep for release
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 891b722..6b0c066 100644 (file)
@@ -180,7 +180,7 @@ sub composed_stats_class {
 __PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC);
 
 # Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90094';
+our $VERSION = '5.90096';
 $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
 
 sub import {
@@ -1632,6 +1632,14 @@ sub uri_for {
 
     my $query = '';
 
+    # remove and save fragment if there is one
+    my $fragment;
+    if ($args =~ s/#(.+)$//) {
+      $fragment = encode_utf8($1);
+      $fragment =~ s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go;
+      $fragment =~ s/ /+/g;
+    }
+
     if (my @keys = keys %$params) {
       # somewhat lifted from URI::_query's query_form
       $query = '?'.join('&', map {
@@ -1660,7 +1668,10 @@ sub uri_for {
     $base =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
     $args = encode_utf8 $args;
     $args =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
-    
+
+    # re-attach fragment on the end of everything after adding params
+    $query .= "#$fragment" if $fragment;
+
     my $res = bless(\"${base}${args}${query}", $class);
     $res;
 }