Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/routing/RouteCompiler.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line diff
--- a/vendor/symfony/routing/RouteCompiler.php Mon Apr 23 09:33:26 2018 +0100 +++ b/vendor/symfony/routing/RouteCompiler.php Mon Apr 23 09:46:53 2018 +0100 @@ -39,10 +39,10 @@ /** * {@inheritdoc} * - * @throws \InvalidArgumentException If a path variable is named _fragment - * @throws \LogicException If a variable is referenced more than once - * @throws \DomainException If a variable name starts with a digit or if it is too long to be successfully used as - * a PCRE subpattern. + * @throws \InvalidArgumentException if a path variable is named _fragment + * @throws \LogicException if a variable is referenced more than once + * @throws \DomainException if a variable name starts with a digit or if it is too long to be successfully used as + * a PCRE subpattern */ public static function compile(Route $route) { @@ -210,7 +210,7 @@ for ($i = 0, $nbToken = count($tokens); $i < $nbToken; ++$i) { $regexp .= self::computeRegexp($tokens, $i, $firstOptional); } - $regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : ''); + $regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'sD'.($isHost ? 'i' : ''); // enable Utf8 matching if really required if ($needsUtf8) { @@ -223,7 +223,7 @@ } return array( - 'staticPrefix' => 'text' === $tokens[0][0] ? $tokens[0][1] : '', + 'staticPrefix' => self::determineStaticPrefix($route, $tokens), 'regex' => $regexp, 'tokens' => array_reverse($tokens), 'variables' => $variables, @@ -231,6 +231,26 @@ } /** + * Determines the longest static prefix possible for a route. + * + * @return string The leading static part of a route's path + */ + private static function determineStaticPrefix(Route $route, array $tokens) + { + if ('text' !== $tokens[0][0]) { + return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1]; + } + + $prefix = $tokens[0][1]; + + if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) { + $prefix .= $tokens[1][1]; + } + + return $prefix; + } + + /** * Returns the next static character in the Route pattern that will serve as a separator. * * @param string $pattern The route pattern