Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e16c666

Browse filesBrowse files
committed
[Routing] made an empty path info to redirect to / (as for any other route that ends with a /)
1 parent f46c6f7 commit e16c666
Copy full SHA for e16c666

File tree

Expand file treeCollapse file tree

4 files changed

+2
-16
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+2
-16
lines changed

‎src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function dump(array $options = array())
7070
$regexes[] = sprintf("%sRewriteCond %%{PATH_INFO} %s\nRewriteRule .* %s [QSA,L,%s]", $conditions, $regex, $options['script_name'], $variables);
7171

7272
// add redirect for missing trailing slash
73-
if ('/$' === substr($regex, -2) && '^/$' !== $regex) {
73+
if ('/$' === substr($regex, -2)) {
7474
$regexes[count($regexes)-1] .= sprintf("\nRewriteCond %%{PATH_INFO} %s\nRewriteRule .* /$0/ [QSA,L,R=301]", substr($regex, 0, -2).'$');
7575
}
7676
}

‎src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected function addMatcher()
6262

6363
$hasTrailingSlash = false;
6464
if (!count($compiledRoute->getVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
65-
if (substr($m['url'], -1) === '/' && $m['url'] !== '/') {
65+
if (substr($m['url'], -1) === '/') {
6666
$conditions[] = sprintf("rtrim(\$url, '/') === '%s'", rtrim(str_replace('\\', '', $m['url']), '/'));
6767
$hasTrailingSlash = true;
6868
} else {

‎src/Symfony/Component/Routing/Matcher/UrlMatcher.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Matcher/UrlMatcher.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ protected function mergeDefaults($params, $defaults)
101101

102102
protected function normalizeUrl($url)
103103
{
104-
// ensure that the URL starts with a /
105-
if ('/' !== substr($url, 0, 1)) {
106-
throw new \InvalidArgumentException(sprintf('URL "%s" is not valid (it does not start with a /).', $url));
107-
}
108-
109104
// remove the query string
110105
if (false !== $pos = strpos($url, '?')) {
111106
$url = substr($url, 0, $pos);

‎tests/Symfony/Tests/Component/Routing/Matcher/UrlMatcherTest.php

Copy file name to clipboardExpand all lines: tests/Symfony/Tests/Component/Routing/Matcher/UrlMatcherTest.php
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ public function testNormalizeUrl()
2828
$this->assertEquals('/foo/bar', $matcher->normalizeUrl('/foo//bar'), '->normalizeUrl() removes duplicated /');
2929
}
3030

31-
/**
32-
* @expectedException \InvalidArgumentException
33-
*/
34-
public function testNormalizeUrlThrowsAnExceptionIfTheUrlIsInvalid()
35-
{
36-
$matcher = new UrlMatcherForTests(new RouteCollection(), array(), array());
37-
$matcher->normalizeUrl('');
38-
}
39-
4031
public function testMatch()
4132
{
4233
// test the patterns are matched are parameters are returned

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.