Closed
Description
Symfony version(s) affected: master
Description
Routes are not recognized when using one dynamic on one hand, and one with a specified host on the other hand.
How to reproduce
Here is a simple PHPUnit test :
public function testDynamic()
{
$routes = new RouteCollection();
$routes->add('a_host', new Route('/', [], [], [], 'api.example.com'));
$routes->add('a_dot', new Route('/a/{letter}.dot', [], [], [], 'localhost'));
$routes->add('a_dot_any_host', new Route('/b/{letter}.dot'));
$dumper = new PhpMatcherDumper($routes);
eval(substr($dumper->dump(), 5));
$context = new RequestContext();
$urlMatcher = new \ProjectUrlMatcher($context);
$this->assertInternalType('array', $urlMatcher->match('/a/a.dot'));
$this->assertInternalType('array', $urlMatcher->match('/b/a.dot'));
}
The second test will raise a Symfony\Component\Routing\Exception\ResourceNotFoundException
.
Possible Solution
I think the host pattern is too greedy in the dynamic host routes compilation and should not match /
as well as .
, as it was in previous commit.
See https://github.com/symfony/symfony/pull/27511/files#diff-3b72491a9ba1cff58442b845ae837eb3R382
Additional context
The problem occurs if you specify a route with a specified host and the profiler : the exception.css
route of the profiler doesn't match...