Skip to content

Commit 86f068e

Browse files
committed
docs(Router): document multi-digit back-references and add single-capture $10 test
1 parent 31dfc6e commit 86f068e

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
@@ -1062,6 +1062,13 @@ public static function provideMultipleSegmentsParamTrueWithManyPlaceholders(): i
10621062
'a/b/c/d/e/f/g/h/i/j',
10631063
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', ''],
10641064
];
1065+
1066+
yield 'single capture with out-of-range multi-digit reference' => [
1067+
'product/(:segment)',
1068+
'Catalog::lookup/$10',
1069+
'product/foo',
1070+
[''],
1071+
];
10651072
}
10661073

10671074
public function testLogsRouteAttributeInstantiationFailureWithContext(): void

0 commit comments

Comments
 (0)