<p dir="auto"><strong>Symfony version(s) affected</strong>: master</p>
<p dir="auto"><strong>Description</strong><br>
Routes are not recognized when using one dynamic on one hand, and one with a specified host on the other hand.</p>
<p dir="auto"><strong>How to reproduce</strong><br>
Here is a simple PHPUnit test :</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    public function testDynamic()
    {
        $routes = new RouteCollection();
        $routes-&gt;add('a_host', new Route('/', [], [], [], 'api.example.com'));
        $routes-&gt;add('a_dot', new Route('/a/{letter}.dot', [], [], [], 'localhost'));
        $routes-&gt;add('a_dot_any_host', new Route('/b/{letter}.dot'));

        $dumper = new PhpMatcherDumper($routes);
        eval(substr($dumper-&gt;dump(), 5));

        $context = new RequestContext();
        $urlMatcher = new \ProjectUrlMatcher($context);
        $this-&gt;assertInternalType('array', $urlMatcher-&gt;match('/a/a.dot'));
        $this-&gt;assertInternalType('array', $urlMatcher-&gt;match('/b/a.dot'));
    }"><pre class="notranslate">    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">testDynamic</span>()
    {
        <span class="pl-s1"><span class="pl-c1">$</span>routes</span> = <span class="pl-k">new</span> <span class="pl-v">RouteCollection</span>();
        <span class="pl-s1"><span class="pl-c1">$</span>routes</span>-&gt;<span class="pl-en">add</span>(<span class="pl-s">'a_host'</span>, <span class="pl-k">new</span> <span class="pl-v">Route</span>(<span class="pl-s">'/'</span>, [], [], [], <span class="pl-s">'api.example.com'</span>));
        <span class="pl-s1"><span class="pl-c1">$</span>routes</span>-&gt;<span class="pl-en">add</span>(<span class="pl-s">'a_dot'</span>, <span class="pl-k">new</span> <span class="pl-v">Route</span>(<span class="pl-s">'/a/{letter}.dot'</span>, [], [], [], <span class="pl-s">'localhost'</span>));
        <span class="pl-s1"><span class="pl-c1">$</span>routes</span>-&gt;<span class="pl-en">add</span>(<span class="pl-s">'a_dot_any_host'</span>, <span class="pl-k">new</span> <span class="pl-v">Route</span>(<span class="pl-s">'/b/{letter}.dot'</span>));

        <span class="pl-s1"><span class="pl-c1">$</span>dumper</span> = <span class="pl-k">new</span> <span class="pl-v">PhpMatcherDumper</span>(<span class="pl-s1"><span class="pl-c1">$</span>routes</span>);
        eval(substr(<span class="pl-s1"><span class="pl-c1">$</span>dumper</span>-&gt;<span class="pl-en">dump</span>(), <span class="pl-c1">5</span>));

        <span class="pl-s1"><span class="pl-c1">$</span>context</span> = <span class="pl-k">new</span> <span class="pl-v">RequestContext</span>();
        <span class="pl-s1"><span class="pl-c1">$</span>urlMatcher</span> = <span class="pl-k">new</span> \<span class="pl-v">ProjectUrlMatcher</span>(<span class="pl-s1"><span class="pl-c1">$</span>context</span>);
        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">assertInternalType</span>(<span class="pl-s">'array'</span>, <span class="pl-s1"><span class="pl-c1">$</span>urlMatcher</span>-&gt;<span class="pl-en">match</span>(<span class="pl-s">'/a/a.dot'</span>));
        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">assertInternalType</span>(<span class="pl-s">'array'</span>, <span class="pl-s1"><span class="pl-c1">$</span>urlMatcher</span>-&gt;<span class="pl-en">match</span>(<span class="pl-s">'/b/a.dot'</span>));
    }</pre></div>
<p dir="auto">The second test will raise a <code class="notranslate">Symfony\Component\Routing\Exception\ResourceNotFoundException</code>.</p>
<p dir="auto"><strong>Possible Solution</strong></p>
<p dir="auto">I think the host pattern is too greedy in the dynamic host routes compilation and should not match <code class="notranslate">/</code> as well as <code class="notranslate">.</code>, as it was in previous commit.</p>
<p dir="auto">See <a href="https://github.com/symfony/symfony/pull/27511/files#diff-3b72491a9ba1cff58442b845ae837eb3R382">https://github.com/symfony/symfony/pull/27511/files#diff-3b72491a9ba1cff58442b845ae837eb3R382</a></p>
<p dir="auto"><strong>Additional context</strong></p>
<p dir="auto">The problem occurs if you specify a route with a specified host and the profiler : the <code class="notranslate">exception.css</code> route of the profiler doesn't match...</p>
<p dir="auto"><strong>Symfony version(s) affected</strong>: 4.1.1</p>
<p dir="auto"><strong>Description</strong><br>
We have a URL with a variable that will contain a dot, but that doesn't work under Symfony 4.1.1 any more when there is another route that has a <code class="notranslate">host</code> requirement set.</p>
<p dir="auto"><strong>How to reproduce</strong></p>
<ol dir="auto">
<li>Put the following in <code class="notranslate">routes.yaml</code>:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="foo:
  path: /foo
  host: 'foo.example.com'
  controller: foo_controller

bar:
  path: /bar/{baz}
  controller: baz_controller"><pre class="notranslate"><code class="notranslate">foo:
  path: /foo
  host: 'foo.example.com'
  controller: foo_controller

bar:
  path: /bar/{baz}
  controller: baz_controller
</code></pre></div>
<ol start="2" dir="auto">
<li>Try to visit <code class="notranslate">/bar/abc.123</code></li>
</ol>
<p dir="auto">When you remove <code class="notranslate">host: 'foo.example.com'</code> from the <code class="notranslate">foo</code> route it <em>does</em> work.</p>