diff --git a/lib/Dancer2/Core/Request.pm b/lib/Dancer2/Core/Request.pm index 059453c31..9cd1689f7 100644 --- a/lib/Dancer2/Core/Request.pm +++ b/lib/Dancer2/Core/Request.pm @@ -282,7 +282,7 @@ sub dispatch_path { $path =~ s|^/+|/|; # PSGI spec notes that '' should be considered '/' $path = '/' if $path eq ''; - return $path; + return Encode::decode('utf8', $path); } sub uri_for { diff --git a/t/utf8.t b/t/utf8.t new file mode 100644 index 000000000..3b8d6392c --- /dev/null +++ b/t/utf8.t @@ -0,0 +1,33 @@ +use utf8; +use strict; +use warnings; + +use Test::More; +use Plack::Test; +use HTTP::Request::Common; +use Encode; + +my $utf8 = 'ľščťžýáí'; + +{ + package MyApp; + + use Dancer2; + use utf8; + + get '/ľščťžýáí' => sub { + return 'ľščťžýáí'; + }; +} + +my $app = Dancer2->psgi_app; + +test_psgi $app, sub { + my $cb = shift; + + my $res = $cb->( GET '/ľščťžýáí' ); + is $res->code, 200; + is Encode::decode('utf8', $res->content), 'ľščťžýáí'; +}; + +done_testing();