Skip to content

Commit

Permalink
Bugfix: fixed issue where the home path was never empty during the ch…
Browse files Browse the repository at this point in the history
…eck in the router
  • Loading branch information
mfrankruijter committed Aug 10, 2020
1 parent 4d5415d commit 90831b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.0.1 - 2020-08-10

### Fixed
- Issue with home path never being empty during the check in the router.

## 1.0.0 - 2020-08-08

### Added
- The initial implementation of the package.

# Versions
- [1.0.0 > Unreleased](https://github.com/ulrack/web/compare/1.0.0...HEAD)
- [1.0.1 > Unreleased](https://github.com/ulrack/web/compare/1.0.1...HEAD)
- [1.0.0 > 1.0.1](https://github.com/ulrack/web/compare/1.0.0...1.0.1)
4 changes: 2 additions & 2 deletions src/Component/Router/PathMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __invoke(

if ($routePath === '') {
return [
'path' => $path,
'path' => trim($path, '/'),
'parameters' => []
];
}
Expand Down Expand Up @@ -90,6 +90,6 @@ private function stripPath(string $path, string $strip): string
return preg_replace(sprintf(
'/^%s/',
preg_quote($strip . '/', '/')
), '', $path, 1);
), '', trim($path, '/') . '/', 1);
}
}
6 changes: 3 additions & 3 deletions tests/Component/Router/PathMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public function routeDataProvider(): array
'/foo/bar/baz/1/',
'foo/bar/baz/1',
[
'path' => 'foo/bar/baz/1',
'path' => '',
'parameters' => []
]
],
[
'foo/bar/baz/1',
'foo/bar/baz/1',
[
'path' => 'foo/bar/baz/1',
'path' => '',
'parameters' => []
]
],
Expand All @@ -83,7 +83,7 @@ public function routeDataProvider(): array
'foo/bar/baz/{param1}',
'foo/bar/baz/1',
[
'path' => 'foo/bar/baz/1',
'path' => '',
'parameters' => [
'param1' => 1
]
Expand Down

0 comments on commit 90831b3

Please sign in to comment.