Skip to content

Commit

Permalink
fixed trim for /
Browse files Browse the repository at this point in the history
  • Loading branch information
kayalion committed Sep 16, 2016
1 parent d7098d1 commit d884e00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ride/lib-router",
"description": "Router library of the Ride framework",
"license": "MIT",
"version": "0.2.2",
"version": "0.2.3",
"authors": [
{
"name": "Joris Vandeweerd",
Expand Down
12 changes: 9 additions & 3 deletions src/ride/library/router/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,17 @@ protected function setPath($path) {
throw new RouterException('Could not set the path of the route: ' . $path . ' is not a valid HTTP path');
}

if (substr($path, 0, 1) != '/') {
$path = '/' . $path;
if ($path !== '/') {
if (substr($path, 0, 1) !== '/') {
$path = '/' . $path;
}

if (substr($path, -1) === '/') {
$path = substr($path, 0, -1);
}
}

$this->path = rtrim($path, '/');
$this->path = $path;
}

/**
Expand Down

0 comments on commit d884e00

Please sign in to comment.