Skip to content

Commit

Permalink
fix: move catch-all-regex to the end (#9185)
Browse files Browse the repository at this point in the history
* fix: move catch-all-regex to the end

part of #9182

* changelog
  • Loading branch information
dummdidumm authored Feb 23, 2023
1 parent b3c31a1 commit 2c44da0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-pumpkins-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-vercel': patch
---

fix: move catch-all-regex to the end
11 changes: 6 additions & 5 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ const plugin = function (defaults = {}) {
/** @type {import('@sveltejs/kit').RouteDefinition<any>[]} */ (group.routes)
);

if (singular) {
// Special case: One function for all routes
static_config.routes.push({ src: '/.*', dest: `/${name}` });
}

for (const route of group.routes) {
functions.set(route.pattern.toString(), name);
}
Expand Down Expand Up @@ -286,6 +281,12 @@ const plugin = function (defaults = {}) {
}
}

if (singular) {
// Common case: One function for all routes
// Needs to happen after ISR or else regex swallows all other matches
static_config.routes.push({ src: '/.*', dest: `/fn` });
}

builder.log.minor('Copying assets...');

builder.writeClient(dirs.static);
Expand Down

0 comments on commit 2c44da0

Please sign in to comment.