App-yajg
view release on metacpan or search on metacpan
* change dependency from JSON::XS to JSON
[BUGFIXES]
* fix bug with --no-filename
* fix bug with --boolean on some systems
* fix bug with "'" at perl output
0.18 -- Sun, 08 Jan 2017 22:35:21 +0300
[CHANGES]
* remove dependency from the URI::Split
* decode uri symbols at fragment and path for --url-parse
* --invert-match option
* --boolean option
* --select-tiny option
[BUGFIXES]
* correct parsing of the urls query
0.17 -- Sat, 07 Jan 2017 16:27:30 +0300
[BUGFIXES]
* Fix utf8 bugs
lib/App/yajg/Hooks.pm view on Meta::CPAN
s/\%([a-f\d]{2})/pack("C",hex($1))/ieg;
utf8::decode($_) unless utf8::is_utf8($_);
return $_;
}
# Do not use URI for increase speed
sub uri_parse {
return unless defined $_[0] and not ref $_[0];
my %uri;
# From URI::Split::uri_split
@uri{qw/scheme host path query fragment/} =
$_[0] =~ m,(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?,;
return unless defined $uri{'host'};
$uri{'uri'} = $_[0];
$uri{'path'} = [
map { _decode_uri($_) } split '/' => $uri{'path'} =~ s,^/,,r
];
# From URI::_query::query_form
$uri{'query'} = {
map { _decode_uri($_) }
map { /=/ ? split(/=/, $_, 2) : ($_ => undef) }
split /[&;]/ => ($uri{'query'} // '')
};
$uri{'fragment'} = _decode_uri($uri{'fragment'});
$_[0] = \%uri;
}
sub make_code_hook ($) {
my $code = shift;
utf8::decode($code) unless utf8::is_utf8($code);
return sub {
local $_ = $_[0];
{ no strict; no warnings; eval $code; }
warn "$@\n" if $@;
t/06-hooks.t view on Meta::CPAN
is $true, 'true', 'True';
is $false, 'false', 'False';
done_testing();
};
subtest 'uri_parse' => sub {
my %tests = (
'abc.com' => 'abc.com',
'/d/d' => '/d/d',
'//example.com' => {
'fragment' => undef,
'host' => 'example.com',
'path' => [],
'query' => {},
'scheme' => undef,
'uri' => '//example.com'
},
'http://example.com/1/2/3//4?sd=33&a&b&c#123' => {
'fragment' => 123,
'host' => 'example.com',
'path' => [
1,
2,
3,
'',
4
],
'query' => {
'a' => undef,
'b' => undef,
'c' => undef,
'sd' => 33
},
'scheme' => 'http',
'uri' => 'http://example.com/1/2/3//4?sd=33&a&b&c#123'
},
'someproto://?e=%D1%85' => {
'fragment' => undef,
'host' => '',
'path' => [],
'query' => {
'e' => 'Ñ
'
},
'scheme' => 'someproto',
'uri' => 'someproto://?e=%D1%85'
},
'http://example.com/1/2/3//4/%D1%8B?sd=33&a&b&c&=23&=13&%D1%8B=%D1%8B#123%D1%8B' => {
'fragment' => '123Ñ',
'host' => 'example.com',
'path' => [
1,
2,
3,
'',
4,
'Ñ',
],
'query' => {
( run in 2.780 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )