Skip to content

Commit e4cc374

Browse files
committed
refactor: replace generator with function returning a list
1 parent 28836f2 commit e4cc374

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/router/utils.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ let _explodeOptionalSegments = (path: string): string[] => {
487487
* - `/one/three/:five` (because `/one/three/:four` has priority)
488488
* - `/one/:two/three/:five` (because `/one/:two/three/:four` has priority)
489489
*/
490-
let explodeOptionalSegments = function* (path: string) {
490+
let explodeOptionalSegments = (path: string) => {
491+
let result: string[] = [];
491492
// Compute hash for dynamic path segments
492493
// /one/:two/three/:four -> /one/:/three/:
493494
let dynamicHash = (subpath: string) =>
@@ -510,12 +511,13 @@ let explodeOptionalSegments = function* (path: string) {
510511

511512
// for absolute paths, ensure `/` instead of empty segment
512513
if (path.startsWith("/") && exploded === "") {
513-
yield "/";
514+
result.push("/");
514515
continue;
515516
}
516517

517-
yield exploded;
518+
result.push(exploded);
518519
}
520+
return result;
519521
};
520522

521523
function rankRouteBranches(branches: RouteBranch[]): void {

0 commit comments

Comments
 (0)