Skip to content

Commit 939a036

Browse files
committed
don't use lookbehind regex
1 parent 7c552fa commit 939a036

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/start/src/router/routes.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ function defineRoutes(fileRoutes: Route[]) {
3333
});
3434

3535
if (!parentRoute) {
36-
routes.push({
37-
...route,
38-
id,
39-
path: id
40-
// strip out escape group for escaping nested routes - e.g. foo(bar) -> foo
41-
.replace(/\/\([^)/]+\)/g, "")
42-
.replace(/\([^)/]+\)/g, "")
43-
// replace . with / for flat routes - e.g. foo.bar -> foo/bar
44-
// ensures that ... of splat routes is not replaced
45-
.replace(/(?<!\.)\.(?!\.)/g, "/")
46-
});
36+
const path = id
37+
// strip out escape group for escaping nested routes - e.g. foo(bar) -> foo
38+
.replace(/\/\([^)/]+\)/g, "")
39+
.replace(/\([^)/]+\)/g, "")
40+
// replace . with / for flat routes - e.g. foo.bar -> foo/bar
41+
.replace(/\./g, "/")
42+
// converts any splat route ... that got replaced back from ///
43+
// this could be avoided with a lookbehind regex but safar has only supported them since mid 2023
44+
.replace("///", "...");
45+
46+
routes.push({ ...route, id, path });
4747
return routes;
4848
}
4949
processRoute(

0 commit comments

Comments
 (0)