Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/46-wildcard-merge-params'
Browse files Browse the repository at this point in the history
Close #47
Fixes #46
  • Loading branch information
weierophinney committed Jun 18, 2018
2 parents 21f0fab + 4b9fffa commit f5dbec5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 3.1.0 - TBD
## 3.1.0 - 2018-06-18

### Added

- Nothing.

### Changed

- Nothing.

### Deprecated

- Nothing.
Expand All @@ -18,7 +22,10 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#47](https://github.com/zendframework/zend-router/pull/47) fixes how the `Wildcard` URL assembly works. Previously, it would
attempt to `rawurlencode()` all values provided to the method as merged with any default values.
It now properly skips any non-scalar values when assembling the URL path. This fixes an issue
discovered when providing an array of middleware as a `middleware` default route parameter.

## 3.0.2 - 2016-05-31

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.0-dev",
"dev-develop": "3.1-dev"
"dev-master": "3.1.x-dev",
"dev-develop": "3.2.x-dev"
},
"zf": {
"component": "Zend\\Router",
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/Http/Wildcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ public function assemble(array $params = [], array $options = [])

if ($mergedParams) {
foreach ($mergedParams as $key => $value) {
$elements[] = rawurlencode($key) . $this->keyValueDelimiter . rawurlencode($value);
if (! is_scalar($value)) {
continue;
}

$elements[] = rawurlencode($key) . $this->keyValueDelimiter . rawurlencode($value);
$this->assembledParams[] = $key;
}

Expand Down
15 changes: 15 additions & 0 deletions test/Http/WildcardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,19 @@ public function testEncodedDecode()

$this->assertSame($out, $match->getParam('foo'));
}

public function testPathAssemblyShouldSkipAnyNonScalarValues()
{
$route = new Wildcard('/', '/', [
'action' => 'index',
'controller' => 'index',
'middleware' => [
\Some\ConnectMiddleware::class,
\Some\Handler::class,
],
]);

$path = $route->assemble();
$this->assertEquals('/action/index/controller/index', $path);
}
}

0 comments on commit f5dbec5

Please sign in to comment.