Merge branch 'master' of https://github.com/revmischa/catalyst-runtime into revmischa...
John Napiorkowski [Mon, 27 Jul 2015 14:22:23 +0000 (09:22 -0500)]
README.mkdn
lib/Catalyst.pm
t/aggregate/unit_core_uri_for.t

index 3fcff0a..74be19d 100644 (file)
@@ -2094,6 +2094,8 @@ konobi: Scott McWhirter <konobi@cpan.org>
 
 marcus: Marcus Ramberg <mramberg@cpan.org>
 
+Mischa Spiegelmock <revmischa@cpan.org>
+
 miyagawa: Tatsuhiko Miyagawa <miyagawa@bulknews.net>
 
 mgrimes: Mark Grimes <mgrimes@cpan.org>
index 891b722..9398f71 100644 (file)
@@ -1632,6 +1632,12 @@ sub uri_for {
 
     my $query = '';
 
+    # remove and save fragment if there is one
+    my $fragment;
+    if ($args =~ s/(#.+)$//) {
+      $fragment = $1;
+    }
+
     if (my @keys = keys %$params) {
       # somewhat lifted from URI::_query's query_form
       $query = '?'.join('&', map {
@@ -1660,7 +1666,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;
 }
index 3318192..d3696a2 100644 (file)
@@ -59,14 +59,11 @@ is(
     'Plus is not encoded'
 );
 
-TODO: {
-    local $TODO = 'broken by 5.7008';
-    is(
-        Catalyst::uri_for( $context, '/bar#fragment', { param1 => 'value1' } )->as_string,
-        'http://127.0.0.1/foo/bar?param1=value1#fragment',
-        'URI for path with fragment and query params'
-    );
-}
+is(
+    Catalyst::uri_for( $context, '/bar#fragment', { param1 => 'value1' } )->as_string,
+    'http://127.0.0.1/foo/bar?param1=value1#fragment',
+    'URI for path with fragment and query params'
+);
 
 # test with utf-8
 is(