BarefootJS

 view release on metacpan or  search on metacpan

t/search_params.t  view on Meta::CPAN

    my $absent = BarefootJS->search_params('other=x');
    is(($absent->get('sort') // 'none'), 'none', 'absent key → author default');

    my $empty = BarefootJS->search_params('sort=');
    is(($empty->get('sort') // 'none'), '', 'present-but-empty value is kept, NOT defaulted');
};

# Percent-encoded UTF-8 decodes to characters via the core `utf8::decode`
# builtin (no URI / URI::Escape dependency) — kept here rather than in the
# ASCII-only shared vectors to avoid cross-harness byte/char encoding skew.
subtest 'UTF-8 percent-decoding (core utf8::decode, no URI dep)' => sub {
    my $sp = BarefootJS->search_params('q=%E2%9C%93');
    is $sp->get('q'), "\x{2713}", 'percent-encoded UTF-8 → decoded character (✓)';
};

# Malformed input must degrade, never die (SSR survives junk query strings).
subtest 'lenient parsing never dies' => sub {
    ok lives { BarefootJS->search_params(undef) }, 'undef query';
    ok lives { BarefootJS->search_params('&&&')->get('x') }, 'only separators';
    ok lives { BarefootJS->search_params('=novalue')->get('x') }, 'empty key pair';
};

done_testing;



( run in 3.381 seconds using v1.01-cache-2.11-cpan-7fcb06a456a )