Skip to content

Commit

Permalink
fix: extraction with optional query (#24)
Browse files Browse the repository at this point in the history
* add failing test

* add fix
  • Loading branch information
kbond committed Oct 12, 2022
1 parent cbded3b commit 5ed4ba8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rize/UriTemplate/Node/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function match(Parser $parser, $uri, $params = array(), $strict = false)
$op = $this->operator;

// check expression operator first
if ($op->id && $uri[0] !== $op->id) {
if ($op->id && isset($uri[0]) && $uri[0] !== $op->id) {
return array($uri, $params);
}

Expand Down
8 changes: 8 additions & 0 deletions test/Rize/UriTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,14 @@ public function dataExtraction()
'number' => 0,
),
),
array(
'/some/{path}{?ref}',
'/some/foo',
array(
'path' => 'foo',
'ref' => null,
),
),
);
}

Expand Down

0 comments on commit 5ed4ba8

Please sign in to comment.