Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(edgeone): correctly convert wildcard routes to regex
The previous two-pass replacement turned '/**' into '/(.([^/]+))' because
the single-* pass matched the '*' inside the '(.*)' produced by the first
pass, causing static asset routes to bypass the filesystem handler.
  • Loading branch information
pi0 committed Apr 14, 2026
commit 06929164b823a217677fae8182f8a7392b1165ce
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ staticwebapp.config.json
playground/firebase.json
.zeabur
.apphosting
.edgeone

test/fixture/functions
.data
Expand Down
12 changes: 5 additions & 7 deletions src/presets/edgeone/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ interface EdgeOneConfig {
function routeToRegex(route: string): string {
return (
"^" +
route
// Handle wildcard "**" (catch-all)
.replace(/\*\*/g, "(.*)")
// Handle single wildcard "*"
.replace(/(?<!\()\*/g, "([^/]+)")
// Handle named params like :id, :slug
.replace(/:([^/]+)/g, "([^/]+)") +
route.replace(/\*\*|\*|:[^/]+/g, (m) => {
if (m === "**") return "(.*)";
if (m === "*") return "([^/]+)";
return "([^/]+)";
}) +
"$"
);
}
Expand Down