[Routing] removing the routing hack where we add a / at the beginning if it does not exist

This commit is contained in:
Fabien Potencier 2011-02-21 10:25:22 +01:00
parent 52f4d81a2d
commit 9619c7dade
2 changed files with 10 additions and 3 deletions

View File

@ -102,7 +102,7 @@ class UrlMatcher implements UrlMatcherInterface
{
// 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

View File

@ -24,12 +24,19 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
$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