Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix utf8 in url #1143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Dancer2/Core/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
33 changes: 33 additions & 0 deletions t/utf8.t
Original file line number Diff line number Diff line change
@@ -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();