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

Segment route: add fix for optional groups within optional groups #2398

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Zend/Mvc/Router/Http/Segment.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected function buildPath(array $parts, array $mergedParams, $isOptional, $ha
$skippable = true;
$optionalPart = $this->buildPath($part[1], $mergedParams, true, $hasChild);

if ($optionalPart !== null) {
if ($optionalPart !== '') {
$path .= $optionalPart;
$skip = false;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/ZendTest/Mvc/Router/Http/SegmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public static function routeProvider()
null,
array('foo' => 'bar', 'bar' => 'baz')
),
'optional-group-within-optional-group-is-ignored' => array(
new Segment('/:foo[/:bar[/:baz]]', array(), array('bar' => 'baz', 'baz' => 'bat')),
'/bar',
null,
array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat')
),
'non-standard-delimiter-before-parameter' => array(
new Segment('/foo-:bar'),
'/foo-baz',
Expand Down