Skip to content

Commit

Permalink
fix(cloudflare-pages): use predefined wildcards in routes.exclude (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pgraug authored Apr 2, 2024
1 parent 91ef6d0 commit 3cb566e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/presets/cloudflare-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ async function writeCFRoutes(nitro: Nitro) {
"_worker.js",
"_worker.js.map",
"nitro.json",
...explicitPublicAssets.map((dir) =>
withoutLeadingSlash(joinURL(dir.baseURL, "**"))
...routes.exclude.map((path) =>
withoutLeadingSlash(path.replace(/\/\*$/, "/**"))
),
],
});
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default defineNitroConfig({
pages: {
routes: {
include: ["/*"],
exclude: ["/blog/static/*"],
exclude: ["/blog/static/*", "/cf-pages-exclude/*"],
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions test/fixture/public/cf-pages-exclude/not-in-routes-json.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This file shouldn't be under "exclude" in the _routes.json outputted by Cloudflare Pages builds.
It's covered by the "/cf-pages-exclude/*" wildcard.
1 change: 1 addition & 0 deletions test/presets/cloudflare-pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe.skipIf(isWindows)("nitro:preset:cloudflare-pages", async () => {
{
"exclude": [
"/blog/static/*",
"/cf-pages-exclude/*",
"/build/*",
"/_unignored.txt",
"/favicon.ico",
Expand Down

0 comments on commit 3cb566e

Please sign in to comment.