-
-
Save anonymous/27cbeca7efb952cda71a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojo::Base -strict; | |
use Test::More; | |
use Test::Mojo; | |
use Mojolicious::Lite; | |
use JSON::Any; | |
use Mojo::Util qw/url_unescape/; | |
get '/:xyz' => sub { | |
my $c = shift; | |
my $data = $c->param('xyz'); | |
# That's basically what MooseX::Storage::Format::JSON does. | |
my $json = JSON::Any->new(canonical => 1)->objToJson( [$data] ); | |
# And it works just fine without the following line | |
utf8::decode($json) if !utf8::is_utf8($json) and utf8::valid($json); | |
$c->render(text => $json); | |
}; | |
my $t = Test::Mojo->new; | |
$t->get_ok('/foo')->content_is('["foo"]'); | |
my $string = '%C3%B6%C3%A4%C3%BC'; | |
$t->get_ok('/'.$string)->content_is('["'.url_unescape($string).'"]'); | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment