/** * Returns the first part of $routePath that should be evaluated in matchValue(). * If no split string is set (route part is the last in the routes uriPattern), the complete $routePart is returned. * Otherwise the part is returned that matches the specified uriPattern of this route part. * * @param string $routePath The request path to be matched * @return string value to match, or an empty string if $routePath is empty, split string was not found or uriPattern could not be matched * @api */ protected function findValueToMatch($routePath) { if (!isset($routePath) || $routePath === '' || $routePath[0] === '/') { return ''; } if ($this->getUriPattern() === '') { return parent::findValueToMatch($routePath); } $regexPattern = preg_quote($this->getUriPattern(), '/'); $regexPattern = preg_replace('/\\\\{[^}]+\\\\}/', '[^\\/]+', $regexPattern); if ($this->splitString !== '') { $regexPattern .= '(?=' . preg_quote($this->splitString, '/') . ')'; } $matches = array(); preg_match('/^' . $regexPattern . '/', trim($routePath, '/'), $matches); return isset($matches[0]) ? $matches[0] : ''; }