Revision history for Web-Simple
+ - handle empty query parameters
- produce a sensible error for (GET => undef) on 5.8
0.030 - 2014-08-07
(my $params = $_[0]) =~ s/\+/ /g;
my ($name, $value);
foreach my $pair (split(/[&;](?:\s+)?/, $params)) {
- next unless (($name, $value) = split(/=/, $pair, 2)) == 2;
+ $value = 1 unless (($name, $value) = split(/=/, $pair, 2)) == 2;
s/$DECODE/$hex_chr{$1}/gs for ($name, $value);
$_ = decode_utf8 $_ for ($name, $value);
separated by the C<&> character. The arguments added to the request are
one per non-C<:>/C<*> parameter (scalar for normal, arrayref for multiple),
-plus if any C<:>/C<*> specs exist a hashref containing those values.
+plus if any C<:>/C<*> specs exist a hashref containing those values. If a
+parameter has no value, i.e. appears as '?foo&', a value of 1 will be
+captured.
Please note that if you specify a multiple type parameter match, you are
ensured of getting an arrayref for the value, EVEN if the current incoming
use Web::Dispatch::ParamParser;
-my $param_sample = 'foo=bar&baz=quux&foo=%2F';
+my $param_sample = 'foo=bar&baz=quux&foo=%2F&xyzzy';
my $unpacked = {
baz => [
"quux"
foo => [
"bar",
"/"
+ ],
+ xyzzy => [
+ 1
]
};
is_deeply(
- Web::Dispatch::ParamParser::_unpack_params('foo=bar&baz=quux&foo=%2F'),
+ Web::Dispatch::ParamParser::_unpack_params('foo=bar&baz=quux&foo=%2F&xyzzy'),
$unpacked,
'Simple unpack ok'
);
'Unpack cached ok'
);
-sub FakeBody::param { { baz => "quux", foo => [ "bar", "/" ] } }
+sub FakeBody::param { { baz => "quux", foo => [ "bar", "/" ], xyzzy => [ 1 ] } }
my $body_env = {
CONTENT_TYPE => "multipart/form-data",