-
-
Save anonymous/6465366809a78730ff67 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
diff --git a/lib/Mojolicious/Routes/Pattern.pm b/lib/Mojolicious/Routes/Pattern. | |
index d93029f..9eb4037 100644 | |
--- a/lib/Mojolicious/Routes/Pattern.pm | |
+++ b/lib/Mojolicious/Routes/Pattern.pm | |
@@ -85,7 +85,6 @@ sub render { | |
} | |
# Format can be optional | |
- $str ||= '/'; | |
return $render && $format ? "$str.$format" : $str; | |
} | |
diff --git a/lib/Mojolicious/Routes/Route.pm b/lib/Mojolicious/Routes/Route.pm | |
index 0357c4d..7d7ea75 100644 | |
--- a/lib/Mojolicious/Routes/Route.pm | |
+++ b/lib/Mojolicious/Routes/Route.pm | |
@@ -130,7 +130,7 @@ sub render { | |
} | |
# Let parent render | |
- return $path || '/' unless my $parent = $self->parent; | |
+ return $path =~ m!^/! ? $path : "/$path" unless my $parent = $self->parent; | |
return $parent->render($path, $values); | |
} | |
diff --git a/t/mojolicious/pattern.t b/t/mojolicious/pattern.t | |
index 158a48e..1718218 100644 | |
--- a/t/mojolicious/pattern.t | |
+++ b/t/mojolicious/pattern.t | |
@@ -65,7 +65,7 @@ is $pattern->pattern, undef, 'slash has been optimized away'; | |
$pattern->defaults({action => 'index'}); | |
ok !$pattern->match('/test/foo/bar'), 'no result'; | |
is_deeply $pattern->match('/'), {action => 'index'}, 'right structure'; | |
-is $pattern->render, '/', 'right result'; | |
+is $pattern->render, '', 'right result'; | |
# Regex in pattern | |
$pattern = Mojolicious::Routes::Pattern->new('/test/(controller)/:action/(id)', | |
@@ -253,7 +253,7 @@ is $pattern->render($result, 1), '/foo/bar', 'right result'; | |
$pattern = Mojolicious::Routes::Pattern->new('//'); | |
$result = $pattern->match('/', 1); | |
is_deeply $result, {}, 'right structure'; | |
-is $pattern->render($result, 1), '/', 'right result'; | |
+is $pattern->render($result, 1), '', 'right result'; | |
$pattern = Mojolicious::Routes::Pattern->new('0'); | |
$result = $pattern->match('/0', 1); | |
is_deeply $result, {}, 'right structure'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment