From ac73b1cc998766d484f9ce19fd95652917c8443b Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 14 Mar 2023 20:37:39 -0500 Subject: [PATCH 1/2] fix(cloudflare): base strip logic Fixes the strip logic for _config.base. Apparently the negative indexing is a feature of the deprecated substr, not substring. --- .changeset/early-kangaroos-invent.md | 5 +++++ packages/integrations/cloudflare/src/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/early-kangaroos-invent.md diff --git a/.changeset/early-kangaroos-invent.md b/.changeset/early-kangaroos-invent.md new file mode 100644 index 000000000000..e2de069196aa --- /dev/null +++ b/.changeset/early-kangaroos-invent.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +fix `config.base` trimming logic for cloudflare integration `_routes.json` generation diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 2f182d6043a0..1ef58dfcc459 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -156,7 +156,7 @@ export default function createIntegration(args?: Options): AstroIntegration { let pagePath = prependForwardSlash(page.pathname); if (_config.base !== '/') { const base = _config.base.endsWith('/') - ? _config.base.substring(0, -1) + ? _config.base.substring(0, _config.base.length - 1) : _config.base; pagePath = `${base}${pagePath}`; } From 459c7d7daff7ed4c06e6aed016031b6fce064325 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 15 Mar 2023 10:53:49 -0500 Subject: [PATCH 2/2] Update packages/integrations/cloudflare/src/index.ts Co-authored-by: Bjorn Lu --- packages/integrations/cloudflare/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 1ef58dfcc459..6cdfdd96cbbd 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -156,7 +156,7 @@ export default function createIntegration(args?: Options): AstroIntegration { let pagePath = prependForwardSlash(page.pathname); if (_config.base !== '/') { const base = _config.base.endsWith('/') - ? _config.base.substring(0, _config.base.length - 1) + ? _config.base.slice(0, -1) : _config.base; pagePath = `${base}${pagePath}`; }