diff --git a/lib/URI/_query.pm b/lib/URI/_query.pm index 94cb71b5..f8f19137 100644 --- a/lib/URI/_query.pm +++ b/lib/URI/_query.pm @@ -70,7 +70,6 @@ sub query_form { } } return if !defined($old) || !length($old) || !defined(wantarray); - return unless $old =~ /=/; # not a form map { s/\+/ /g; uri_unescape($_) } map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/[&;]/, $old); } diff --git a/t/query.t b/t/query.t index 29708141..a1faf8dc 100644 --- a/t/query.t +++ b/t/query.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 25; use URI (); my $u = URI->new("", "http"); @@ -31,8 +31,9 @@ is $u, "?%20+%2B+%3D+%5B+%5D"; @q = $u->query_keywords; is join(":", @q), " :+:=:[:]"; +# If someone set query keywords than same keywords can be treated as form parameter @q = $u->query_form; -ok !@q; +is join(":", @q ), ' + = [ ]:'; $u->query(" +?=#"); is $u, "?%20+?=%23"; @@ -79,3 +80,10 @@ $u->query_form([]); $u->query_form(a => 1, b => 2); } is $u, "?a=1;b=2"; + +# check if url with single query keyword parsed correctly +my $u1 = URI->new("http://example.com/?foo"); +is $u1->query, 'foo'; + +@q = $u1->query_form; +is join(":", @q), 'foo:';