Skip to content

Commit

Permalink
Merge branch 'release/1.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
kayalion committed Feb 8, 2017
2 parents 76d8cb3 + 568b78f commit ed7d7ef
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
# Changelog

## 1.3.3 - 2017-02-08
### Updated
- Enforce route slash

## 1.3.2 - 2016-09-16
### Updated
- Fixed trim for /

## 1.3.1 - 2016-09-14
### Updated
- Fixed incoming path /// trim

## 1.3.0
### Added
- Route: added permissions for the security layer

## 1.2.1
### Updated
- moved tests to dev autoloader
- updated readme

## 1.2.0
### Updated
- Route: added default parameter to getArgument and getQueryParameter
7 changes: 6 additions & 1 deletion src/ride/library/router/AbstractRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,16 @@ protected function processPath($path) {
$path = substr($path, 0, $positionQuestion);
}

// remove trailing slash
if ($path != '/') {
// remove trailing slash
if (substr($path, -1, 1) != '/') {
$path = rtrim($path, '/');
}

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

return $path;
Expand Down
20 changes: 15 additions & 5 deletions test/src/ride/library/router/GenericRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,28 @@ public function testRoute() {
$result = $router->route($method, $path);
$this->assertTrue($result->isEmpty());

$route = new Route($path, 'callback');
$container->setRoute(new Route('/', 'callback'));
$container->setRoute($route);
$result = $router->route($method, '?only_query');
$this->assertTrue($result->isEmpty());

$rootRoute = new Route('/', 'callback');
$pathRoute = new Route($path, 'callback');

$container->setRoute($rootRoute);
$container->setRoute($pathRoute);

$result = $router->route($method, $path);
$this->assertFalse($result->isEmpty());
$this->assertEquals($route, $result->getRoute());
$this->assertEquals($pathRoute, $result->getRoute());
$this->assertNull($result->getAllowedMethods());

$result = $router->route($method, $path . '?foo=bar');
$this->assertFalse($result->isEmpty());
$this->assertEquals($route, $result->getRoute());
$this->assertEquals($pathRoute, $result->getRoute());
$this->assertNull($result->getAllowedMethods());

$result = $router->route($method, '?only_query');
$this->assertFalse($result->isEmpty());
$this->assertEquals($rootRoute, $result->getRoute());
$this->assertNull($result->getAllowedMethods());
}

Expand Down

0 comments on commit ed7d7ef

Please sign in to comment.