mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 12:32:14 +00:00
Fixed for PHP7
This commit is contained in:
@@ -163,16 +163,6 @@ abstract class Route implements IRoute
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get name of last param
|
// Get name of last param
|
||||||
/*$lastParam = null;
|
|
||||||
$start = strrpos($route, '{');
|
|
||||||
if($start > -1) {
|
|
||||||
$param = substr($route, $start, strrpos($route, '}') + 1 - $start);
|
|
||||||
if(str_ends_with($route, $param . '/')) {
|
|
||||||
$lastParam = $param;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
if (trim($urlRegex) === '' || (bool)preg_match(sprintf($this->urlRegex, $urlRegex), $url, $matches) === false) {
|
if (trim($urlRegex) === '' || (bool)preg_match(sprintf($this->urlRegex, $urlRegex), $url, $matches) === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -195,8 +185,9 @@ abstract class Route implements IRoute
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If last parameter, use slash according to original path (non sanitized version)
|
// If last parameter and slash parameter is enabled, use slash according to original path (non sanitized version)
|
||||||
if ($this->slashParameterEnabled && ($i === count($parameters[1]) - 1) && str_ends_with($route, $this->paramModifiers[0] . $name . $this->paramModifiers[1] . '/') && $originalPath[strlen($originalPath) - 1] === '/') {
|
$lastParameter = $this->paramModifiers[0] . $name . $this->paramModifiers[1] . '/';
|
||||||
|
if ($this->slashParameterEnabled && ($i === count($parameters[1]) - 1) && (substr_compare($route, $lastParameter, -strlen($lastParameter)) === 0) && $originalPath[strlen($originalPath) - 1] === '/') {
|
||||||
$matches[$name] .= '/';
|
$matches[$name] .= '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user