Skip to content

Commit 4a73609

Browse files
committed
Fixed for PHP7
1 parent 74c5293 commit 4a73609

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/Pecee/SimpleRouter/Route/Route.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,6 @@ protected function parseParameters($route, $url, Request $request, $parameterReg
163163
}
164164

165165
// Get name of last param
166-
/*$lastParam = null;
167-
$start = strrpos($route, '{');
168-
if($start > -1) {
169-
$param = substr($route, $start, strrpos($route, '}') + 1 - $start);
170-
if(str_ends_with($route, $param . '/')) {
171-
$lastParam = $param;
172-
}
173-
}*/
174-
175-
176166
if (trim($urlRegex) === '' || (bool)preg_match(sprintf($this->urlRegex, $urlRegex), $url, $matches) === false) {
177167
return null;
178168
}
@@ -195,8 +185,9 @@ protected function parseParameters($route, $url, Request $request, $parameterReg
195185
continue;
196186
}
197187

198-
// If last parameter, use slash according to original path (non sanitized version)
199-
if ($this->slashParameterEnabled && ($i === count($parameters[1]) - 1) && str_ends_with($route, $this->paramModifiers[0] . $name . $this->paramModifiers[1] . '/') && $originalPath[strlen($originalPath) - 1] === '/') {
188+
// If last parameter and slash parameter is enabled, use slash according to original path (non sanitized version)
189+
$lastParameter = $this->paramModifiers[0] . $name . $this->paramModifiers[1] . '/';
190+
if ($this->slashParameterEnabled && ($i === count($parameters[1]) - 1) && (substr_compare($route, $lastParameter, -strlen($lastParameter)) === 0) && $originalPath[strlen($originalPath) - 1] === '/') {
200191
$matches[$name] .= '/';
201192
}
202193

0 commit comments

Comments
 (0)