Skip to content

Commit

Permalink
[Routing] removing the routing hack where we add a / at the beginning…
Browse files Browse the repository at this point in the history
… if it does not exist
  • Loading branch information
fabpot committed Feb 21, 2011
1 parent 52f4d81 commit 9619c7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Matcher/UrlMatcher.php
Expand Up @@ -102,7 +102,7 @@ protected function normalizeUrl($url)
{
// ensure that the URL starts with a /
if ('/' !== substr($url, 0, 1)) {
$url = '/'.$url;
throw new \InvalidArgumentException(sprintf('URL "%s" is not valid (it does not start with a /).', $url));
}

// remove the query string
Expand Down
11 changes: 9 additions & 2 deletions tests/Symfony/Tests/Component/Routing/Matcher/UrlMatcherTest.php
Expand Up @@ -24,12 +24,19 @@ public function testNormalizeUrl()

$matcher = new UrlMatcherForTests($collection, array(), array());

$this->assertEquals('/', $matcher->normalizeUrl(''), '->normalizeUrl() adds a / at the beginning of the URL if needed');
$this->assertEquals('/foo', $matcher->normalizeUrl('foo'), '->normalizeUrl() adds a / at the beginning of the URL if needed');
$this->assertEquals('/foo', $matcher->normalizeUrl('/foo?foo=bar'), '->normalizeUrl() removes the query string');
$this->assertEquals('/foo/bar', $matcher->normalizeUrl('/foo//bar'), '->normalizeUrl() removes duplicated /');
}

/**
* @expectedException \InvalidArgumentException
*/
public function testNormalizeUrlThrowsAnExceptionIfTheUrlIsInvalid()
{
$matcher = new UrlMatcherForTests(new RouteCollection(), array(), array());
$matcher->normalizeUrl('');
}

public function testMatch()
{
// test the patterns are matched are parameters are returned
Expand Down

0 comments on commit 9619c7d

Please sign in to comment.