Commit 42926bf5 authored by Fabien Potencier's avatar Fabien Potencier

updated Routing component

parent 8b6f476a
...@@ -12,44 +12,14 @@ ...@@ -12,44 +12,14 @@
namespace Silex; namespace Silex;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Matcher\UrlMatcher; use Symfony\Component\Routing\Matcher\RedirectableUrlMatcher as BaseRedirectableUrlMatcher;
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface; use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
use Symfony\Component\Routing\Matcher\Exception\NotFoundException;
/** /**
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher
{ {
private $trailingSlashTest = false;
/**
* @see UrlMatcher::match()
*/
public function match($pathinfo)
{
try {
$parameters = parent::match($pathinfo);
} catch (NotFoundException $e) {
if ('/' === substr($pathinfo, -1)) {
throw $e;
}
// try with a / at the end
$this->trailingSlashTest = true;
return $this->match($pathinfo.'/');
}
if ($this->trailingSlashTest) {
$this->trailingSlashTest = false;
return $this->redirect($pathinfo, null);
}
return $parameters;
}
/** /**
* @see RedirectableUrlMatcherInterface::match() * @see RedirectableUrlMatcherInterface::match()
*/ */
......
Subproject commit 1740f71d38056f317b655bdab09e4a666f5bf65b Subproject commit 7d6ff08b8b9267923da07202308f3a5606128af9
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment