# remove and save fragment if there is one
my $fragment;
- if ($args =~ s/(#.+)$//) {
- $fragment = $1;
+ if ($args =~ s/#(.+)$//) {
+ $fragment = encode_utf8($1);
+ $fragment =~ s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go;
+ $fragment =~ s/ /+/g;
}
if (my @keys = keys %$params) {
$args =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
# re-attach fragment on the end of everything after adding params
- $query .= $fragment if $fragment;
+ $args .= "#$fragment" if $fragment;
my $res = bless(\"${base}${args}${query}", $class);
$res;
sub uri_for :Path('uri_for') {
my ($self, $c) = @_;
$c->response->content_type('text/html');
- $c->response->body("${\$c->uri_for($c->controller('Root')->action_for('argend'), ['♥'], '♥', {'♥'=>'♥♥'})}");
+ $c->response->body("${\$c->uri_for($c->controller('Root')->action_for('argend'), ['♥'], '♥#X♥X', {'♥'=>'♥♥'})}");
}
sub heart_with_arg :Path('a♥') Args(1) {
{
my ($res, $c) = ctx_request "/root/uri_for";
- my $url = $c->uri_for($c->controller('Root')->action_for('argend'), ['♥'], '♥', {'♥'=>'♥♥'});
+ my $url = $c->uri_for($c->controller('Root')->action_for('argend'), ['♥'], '♥#X♥X', {'♥'=>'♥♥'});
is $res->code, 200, 'OK';
is decode_utf8($res->content), "$url", 'correct body'; #should do nothing
is $res->content, "$url", 'correct body';
- is $res->content_length, 90, 'correct length';
+ is $res->content_length, 102, 'correct length';
is $res->content_charset, 'UTF-8';
{