Skip to content

Commit 218e070

Browse files
JusticeMatthewflorian-lefebvreematipico
authored
Fix: Dynamic route split regex (#14108)
* updates route dynamic split regex * changeset * Update .changeset/lemon-tires-yell.md --------- Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
1 parent 68fdf6e commit 218e070

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

.changeset/lemon-tires-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Updates dynamic route split regex to avoid infinite retries/exponential complexity

packages/astro/src/core/routing/manifest/create.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ interface Item {
4141
routeSuffix: string;
4242
}
4343

44-
// Disable eslint as we're not sure how to improve this regex yet
45-
// eslint-disable-next-line regexp/no-super-linear-backtracking
46-
const ROUTE_DYNAMIC_SPLIT = /\[(.+?\(.+?\)|.+?)\]/;
44+
const ROUTE_DYNAMIC_SPLIT = /\[([^[\]()]+(?:\([^)]+\))?)\]/;
4745
const ROUTE_SPREAD = /^\.{3}.+$/;
4846

4947
function getParts(part: string, file: string) {

0 commit comments

Comments
 (0)