File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
src/Symfony/Component/Routing/Matcher
tests/Symfony/Tests/Component/Routing/Matcher Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ protected function normalizeUrl($url)
102102 {
103103 // ensure that the URL starts with a /
104104 if ('/ ' !== substr ($ url , 0 , 1 )) {
105- $ url = ' / ' . $ url ;
105+ throw new \ InvalidArgumentException ( sprintf ( ' URL "%s" is not valid (it does not start with a /). ' , $ url)) ;
106106 }
107107
108108 // remove the query string
Original file line number Diff line number Diff line change @@ -24,12 +24,19 @@ public function testNormalizeUrl()
2424
2525 $ matcher = new UrlMatcherForTests ($ collection , array (), array ());
2626
27- $ this ->assertEquals ('/ ' , $ matcher ->normalizeUrl ('' ), '->normalizeUrl() adds a / at the beginning of the URL if needed ' );
28- $ this ->assertEquals ('/foo ' , $ matcher ->normalizeUrl ('foo ' ), '->normalizeUrl() adds a / at the beginning of the URL if needed ' );
2927 $ this ->assertEquals ('/foo ' , $ matcher ->normalizeUrl ('/foo?foo=bar ' ), '->normalizeUrl() removes the query string ' );
3028 $ this ->assertEquals ('/foo/bar ' , $ matcher ->normalizeUrl ('/foo//bar ' ), '->normalizeUrl() removes duplicated / ' );
3129 }
3230
31+ /**
32+ * @expectedException \InvalidArgumentException
33+ */
34+ public function testNormalizeUrlThrowsAnExceptionIfTheUrlIsInvalid ()
35+ {
36+ $ matcher = new UrlMatcherForTests (new RouteCollection (), array (), array ());
37+ $ matcher ->normalizeUrl ('' );
38+ }
39+
3340 public function testMatch ()
3441 {
3542 // test the patterns are matched are parameters are returned
You can’t perform that action at this time.
0 commit comments