File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
packages/router/src/Routing/Construction Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -50,15 +50,13 @@ public function findOrCreateNodeForSegment(string $routeSegment): self
5050 return $ this ->dynamicPaths [$ regexRouteSegment ] ??= self ::createDynamicRouteNode ($ regexRouteSegment );
5151 }
5252
53- public function setTargetRoute (MarkedRoute $ markedRoute, bool $ allowDuplicate = false ): void
53+ public function setTargetRoute (MarkedRoute $ markedRoute ): void
5454 {
55- if ($ this ->targetRoute !== null && ! $ allowDuplicate ) {
55+ if ($ this ->targetRoute !== null ) {
5656 throw new DuplicateRouteException ($ markedRoute ->route );
5757 }
5858
59- if ($ this ->targetRoute === null ) {
60- $ this ->targetRoute = $ markedRoute ;
61- }
59+ $ this ->targetRoute = $ markedRoute ;
6260 }
6361
6462 private static function convertDynamicSegmentToRegex (string $ uriPart ): string
Original file line number Diff line number Diff line change @@ -28,22 +28,20 @@ public function add(MarkedRoute $markedRoute): void
2828 $ node = $ this ->roots [$ method ->value ] ??= RouteTreeNode::createRootRoute ();
2929
3030 $ segments = $ markedRoute ->route ->split ();
31- $ hasOptionalParams = false ;
3231
3332 // Traverse the tree and find the node for each route segment
3433 foreach ($ segments as $ index => $ routeSegment ) {
3534 $ isOptional = $ this ->isOptionalSegment ($ routeSegment );
3635
3736 if ($ isOptional ) {
38- $ hasOptionalParams = true ;
39- $ node ->setTargetRoute ($ markedRoute , allowDuplicate: true );
37+ $ node ->setTargetRoute ($ markedRoute );
4038 $ routeSegment = $ this ->stripOptionalMarker ($ routeSegment );
4139 }
4240
4341 $ node = $ node ->findOrCreateNodeForSegment ($ routeSegment );
4442 }
4543
46- $ node ->setTargetRoute ($ markedRoute, allowDuplicate: $ hasOptionalParams );
44+ $ node ->setTargetRoute ($ markedRoute );
4745 }
4846
4947 private function isOptionalSegment (string $ segment ): bool
You can’t perform that action at this time.
0 commit comments