[Routing] Fix a regression introduced by #4170
This commit is contained in:
parent
f14961b747
commit
9907df2569
@ -48,10 +48,14 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
if ($req = $route->getRequirement($var)) {
|
||||
$regexp = $req;
|
||||
} else {
|
||||
// Use the character following the variable as the separator when available
|
||||
// Use the character preceding the variable otherwise
|
||||
$separator = $pos !== $len ? $pattern[$pos] : $match[0][0][0];
|
||||
$regexp = sprintf('[^%s]+', preg_quote($separator, self::REGEX_DELIMITER));
|
||||
// Use the character preceding the variable as a separator
|
||||
$separators = array($match[0][0][0]);
|
||||
|
||||
if ($pos !== $len) {
|
||||
// Use the character following the variable as the separator when available
|
||||
$separators[] = $pattern[$pos];
|
||||
}
|
||||
$regexp = sprintf('[^%s]+', preg_quote(implode('', array_unique($separators)), self::REGEX_DELIMITER));
|
||||
}
|
||||
|
||||
$tokens[] = array('variable', $match[0][0][0], $regexp, $var);
|
||||
|
@ -105,6 +105,14 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase
|
||||
array('text', '/foo'),
|
||||
)),
|
||||
|
||||
array(
|
||||
'Route with a format',
|
||||
array('/foo/{bar}.{_format}'),
|
||||
'/foo', '#^/foo/(?<bar>[^/\.]+)\.(?<_format>[^\.]+)$#s', array('bar', '_format'), array(
|
||||
array('variable', '.', '[^\.]+', '_format'),
|
||||
array('variable', '/', '[^/\.]+', 'bar'),
|
||||
array('text', '/foo'),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user