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

Commit f5dbec5

Browse files
committed
Merge branch 'hotfix/46-wildcard-merge-params'
Close #47 Fixes #46
2 parents 21f0fab + 4b9fffa commit f5dbec5

File tree

5 files changed

+32
-7
lines changed

5 files changed

+32
-7
lines changed

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

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

5-
## 3.1.0 - TBD
5+
## 3.1.0 - 2018-06-18
66

77
### Added
88

99
- Nothing.
1010

11+
### Changed
12+
13+
- Nothing.
14+
1115
### Deprecated
1216

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

1923
### Fixed
2024

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

2330
## 3.0.2 - 2016-05-31
2431

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
},
5151
"extra": {
5252
"branch-alias": {
53-
"dev-master": "3.0-dev",
54-
"dev-develop": "3.1-dev"
53+
"dev-master": "3.1.x-dev",
54+
"dev-develop": "3.2.x-dev"
5555
},
5656
"zf": {
5757
"component": "Zend\\Router",

composer.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Http/Wildcard.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ public function assemble(array $params = [], array $options = [])
168168

169169
if ($mergedParams) {
170170
foreach ($mergedParams as $key => $value) {
171-
$elements[] = rawurlencode($key) . $this->keyValueDelimiter . rawurlencode($value);
171+
if (! is_scalar($value)) {
172+
continue;
173+
}
172174

175+
$elements[] = rawurlencode($key) . $this->keyValueDelimiter . rawurlencode($value);
173176
$this->assembledParams[] = $key;
174177
}
175178

test/Http/WildcardTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,19 @@ public function testEncodedDecode()
189189

190190
$this->assertSame($out, $match->getParam('foo'));
191191
}
192+
193+
public function testPathAssemblyShouldSkipAnyNonScalarValues()
194+
{
195+
$route = new Wildcard('/', '/', [
196+
'action' => 'index',
197+
'controller' => 'index',
198+
'middleware' => [
199+
\Some\ConnectMiddleware::class,
200+
\Some\Handler::class,
201+
],
202+
]);
203+
204+
$path = $route->assemble();
205+
$this->assertEquals('/action/index/controller/index', $path);
206+
}
192207
}

0 commit comments

Comments
 (0)