From 98e70f0963b4709d89aeba64646ce328a45c7483 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 26 Apr 2011 14:26:29 +0200 Subject: [PATCH] [Routing] Route collection prefixes must start with a / and must not end with a / --- src/Symfony/Component/Routing/RouteCollection.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index 359c0bfee0..b90c7cb90f 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -120,10 +120,18 @@ class RouteCollection implements \IteratorAggregate */ public function addPrefix($prefix) { + // a prefix must not end with a slash + $prefix = rtrim($prefix, '/'); + if (!$prefix) { return; } + // a prefix must start with a slash + if ('/' !== $prefix[0]) { + $prefix = '/'.$prefix; + } + $this->prefix = $prefix.$this->prefix; foreach ($this->all() as $route) {