Skip to content

Commit 86814ac

Browse files
committed
docs(Router): document multi-digit back-references and add single-capture $10 test
1 parent a088df4 commit 86814ac

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎docs/incoming/routing.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,9 @@ $routes->get('product/(:any)', 'Catalog::productLookup/$1');
10211021

10221022
will match **product/123**, **product/123/456**, **product/123/456/789** and so on. And if the URI is **product/123/456**, `123/456` will be passed to the first parameter of the `Catalog::productLookup()` method.
10231023

1024+
!!! note "Note"
1025+
When this option is enabled, consecutive digits in back-references (such as `$10`) are treated as a single reference rather than `$1` followed by `0`. If a back-reference does not have a matching captured group, it resolves to an empty string (`''`).
1026+
10241027
## Auto Routing (Improved)
10251028

10261029
!!! success "Available from version 4.2.0"

‎tests/system/Router/RouterTest.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,13 @@ public static function provideMultipleSegmentsParamTrueWithManyPlaceholders(): i
10881088
'a/b/c/d/e/f/g/h/i/j',
10891089
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', ''],
10901090
];
1091+
1092+
yield 'single capture with out-of-range multi-digit reference' => [
1093+
'product/(:segment)',
1094+
'Catalog::lookup/$10',
1095+
'product/foo',
1096+
[''],
1097+
];
10911098
}
10921099

10931100
public function testLogsRouteAttributeInstantiationFailureWithContext(): void

0 commit comments

Comments
 (0)