[Routing] removing the routing hack where we add a / at the beginning if it does not exist
This commit is contained in:
parent
52f4d81a2d
commit
9619c7dade
@ -102,7 +102,7 @@ class UrlMatcher implements UrlMatcherInterface
|
|||||||
{
|
{
|
||||||
// ensure that the URL starts with a /
|
// ensure that the URL starts with a /
|
||||||
if ('/' !== substr($url, 0, 1)) {
|
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
|
// remove the query string
|
||||||
|
@ -24,12 +24,19 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$matcher = new UrlMatcherForTests($collection, array(), array());
|
$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', $matcher->normalizeUrl('/foo?foo=bar'), '->normalizeUrl() removes the query string');
|
||||||
$this->assertEquals('/foo/bar', $matcher->normalizeUrl('/foo//bar'), '->normalizeUrl() removes duplicated /');
|
$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()
|
public function testMatch()
|
||||||
{
|
{
|
||||||
// test the patterns are matched are parameters are returned
|
// test the patterns are matched are parameters are returned
|
||||||
|
Reference in New Issue
Block a user