Skip to content

Commit

Permalink
♻️ Change urldecoding location to keep things DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
bramus committed Feb 27, 2019
1 parent 33b3aae commit 492444d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Bramus/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,10 @@ private function handle($routes, $quitAfterRun = false)

// We have a following parameter: take the substring from the current param position until the next one's position (thank you PREG_OFFSET_CAPTURE)
if (isset($matches[$index + 1]) && isset($matches[$index + 1][0]) && is_array($matches[$index + 1][0])) {
return trim(urldecode(substr($match[0][0], 0, $matches[$index + 1][0][1] - $match[0][1])), '/');
return trim(substr($match[0][0], 0, $matches[$index + 1][0][1] - $match[0][1]), '/');
} // We have no following parameters: return the whole lot

return isset($match[0][0]) ? trim(urldecode($match[0][0]), '/') : null;
return isset($match[0][0]) ? trim($match[0][0], '/') : null;
}, $matches, array_keys($matches));

// Call the handling function with the URL parameters if the desired input is callable
Expand Down Expand Up @@ -407,7 +407,7 @@ private function invoke($fn, $params = [])
public function getCurrentUri()
{
// Get the current Request URI and remove rewrite base path from it (= allows one to run the router in a sub folder)
$uri = substr($_SERVER['REQUEST_URI'], strlen($this->getBasePath()));
$uri = substr(rawurldecode($_SERVER['REQUEST_URI']), strlen($this->getBasePath()));

// Don't take query params into account on the URL
if (strstr($uri, '?')) {
Expand Down

0 comments on commit 492444d

Please sign in to comment.