10000 bug #38372 [Routing] fix using !important and defaults/reqs in inline… · lucasaba/symfony@9c8a300 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c8a300

Browse files
bug symfony#38372 [Routing] fix using !important and defaults/reqs in inline route definitions (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Routing] fix using !important and defaults/reqs in inline route definitions | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix symfony#33224 | License | MIT | Doc PR | - Commits ------- 826db22 [Routing] fix using !important and defaults/reqs in inline route definitions
2 parents 9a5a856 + 826db22 commit 9c8a300

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/Routing/Route.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function getPath()
137137
public function setPath($pattern)
138138
{
139139
if (false !== strpbrk($pattern, '?<')) {
140-
$pattern = preg_replace_callback('#\{(\w++)(<.*?>)?(\?[^\}]*+)?\}#', function ($m) {
140+
$pattern = preg_replace_callback('#\{(!?\w++)(<.*?>)?(\?[^\}]*+)?\}#', function ($m) {
141141
if (isset($m[3][0])) {
142142
$this->setDefault($m[1], '?' !== $m[3] ? substr($m[3], 1) : null);
143143
}

src/Symfony/Component/Routing/Tests/RouteTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public function testInlineDefaultAndRequirement()
208208
$this->assertEquals((new Route('/foo/{bar}'))->setDefault('bar', null), new Route('/foo/{bar?}'));
209209
$this->assertEquals((new Route('/foo/{bar}'))->setDefault('bar', 'baz'), new Route('/foo/{bar?baz}'));
210210
$this->assertEquals((new Route('/foo/{bar}'))->setDefault('bar', 'baz<buz>'), new Route('/foo/{bar?baz<buz>}'));
211+
$this->assertEquals((new Route('/foo/{!bar}'))->setDefault('!bar', 'baz<buz>'), new Route('/foo/{!bar?baz<buz>}'));
211212
$this->assertEquals((new Route('/foo/{bar}'))->setDefault('bar', 'baz'), new Route('/foo/{bar?}', ['bar' => 'baz']));
212213

213214
$this->assertEquals((new Route('/foo/{bar}'))->setRequirement('bar', '.*'), new Route('/foo/{bar<.*>}'));

0 commit comments

Comments
 (0)
0