diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index 38c82a85f6..7fc0304211 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -212,7 +212,9 @@ class RouteCollection implements \IteratorAggregate, \Countable // necessarily already have it applied (depending on the order RouteCollections are added to each other) $collection->addPrefix($this->getPrefix() . $prefix, $defaults, $requirements, $options); - $collection->setHostnamePattern($hostnamePattern); + if ('' !== $hostnamePattern) { + $collection->setHostnamePattern($hostnamePattern); + } $this->routes[] = $collection; } @@ -284,10 +286,6 @@ class RouteCollection implements \IteratorAggregate, \Countable { $this->hostnamePattern = (string) $pattern; - if ('' === $pattern) { - return; - } - foreach ($this->routes as $name => $route) { $route->setHostnamePattern($pattern); }