fix test and code, HT: TBSliver json_sugar
Matt S Trout [Tue, 22 Dec 2015 20:39:23 +0000 (20:39 +0000)]
lib/Web/Dispatch/ParamParser.pm
t/json.t

index ef4f78f..b303b83 100644 (file)
@@ -14,7 +14,7 @@ sub ORIG_ENV () { 'Web::Dispatch.original_env' }
 sub get_unpacked_query_from {
   return ($_[0]->{+ORIG_ENV}||$_[0])->{+UNPACKED_QUERY} ||= do {
     my $p = _unpack_params($_[0]->{QUERY_STRING});
-    unless (keys %$p == 1 and exists $p->{j} and ref($p->{j}) eq 'ARRAY' and @{$p->{j}} == 1 and $p->{j} =~ /^{/) {
+    unless (keys %$p == 1 and exists $p->{j} and ref($p->{j}) eq 'ARRAY' and @{$p->{j}} == 1 and $p->{j}[0] =~ /^{/) {
       $p;
     } else {
       require JSON::MaybeXS;
index 76213c4..91aef5b 100644 (file)
--- a/t/json.t
+++ b/t/json.t
@@ -136,4 +136,4 @@ is($query_simple->content, 'bar', 'simple query string ok');
 
 my $query_json = run_request(GET 'http://localhost?j={"foo": "bar"}');
 
-is($query_simple->content, 'bar', 'json query string ok');
+is($query_json->content, 'bar', 'json query string ok');