Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix parameter mapping problem when constraints contain parantheses

  • Loading branch information...
commit 8d63c9a14e576ce386857c8baea1b67859d92189 1 parent 8cb9622
@DASPRiD authored
View
10 library/Zend/Mvc/Router/Http/Segment.php
@@ -211,15 +211,17 @@ protected function buildRegex(array $parts, array $constraints, &$groupIndex = 1
break;
case 'parameter':
+ $groupName = '?P<param' . $groupIndex . '>';
+
if (isset($constraints[$part[1]])) {
- $regex .= '(' . $constraints[$part[1]] . ')';
+ $regex .= '(' . $groupName . $constraints[$part[1]] . ')';
} elseif ($part[2] === null) {
- $regex .= '([^/]+)';
+ $regex .= '(' . $groupName . '[^/]+)';
} else {
- $regex .= '([^' . $part[2] . ']+)';
+ $regex .= '(' . $groupName . '[^' . $part[2] . ']+)';
}
- $this->paramMap[$groupIndex++] = $part[1];
+ $this->paramMap['param' . $groupIndex++] = $part[1];
break;
case 'optional':
View
6 tests/Zend/Mvc/Router/Http/SegmentTest.php
@@ -66,6 +66,12 @@ public static function routeProvider()
null,
array('foo' => 'foo-bar')
),
+ 'constraints-with-parantheses-dont-break-parameter-map' => array(
+ new Segment('/:foo/:bar', array('foo' => '(bar)')),
+ '/bar/baz',
+ null,
+ array('foo' => 'bar', 'bar' => 'baz')
+ ),
'simple-match-with-optional-parameter' => array(
new Segment('/[:foo]', array(), array('foo' => 'bar')),
'/',
Please sign in to comment.
Something went wrong with that request. Please try again.