diff --git a/.changeset/weak-steaks-hang.md b/.changeset/weak-steaks-hang.md new file mode 100644 index 00000000..7d9b2ddd --- /dev/null +++ b/.changeset/weak-steaks-hang.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +Fixes a bug which was caused on windows when splitting static file paths diff --git a/packages/cloudflare/src/utils/generate-routes-json.ts b/packages/cloudflare/src/utils/generate-routes-json.ts index 5d1470db..60f598d1 100644 --- a/packages/cloudflare/src/utils/generate-routes-json.ts +++ b/packages/cloudflare/src/utils/generate-routes-json.ts @@ -2,7 +2,7 @@ import type { AstroConfig, AstroIntegrationLogger, RouteData, RoutePart } from ' import { existsSync } from 'node:fs'; import { writeFile } from 'node:fs/promises'; -import { posix } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { prependForwardSlash, @@ -186,7 +186,7 @@ export async function createRoutesFile( const staticPath = staticFile; const segments = removeLeadingForwardSlash(staticPath) - .split(posix.sep) + .split(path.sep) .filter(Boolean) .map((s: string) => { return getParts(s); @@ -232,7 +232,7 @@ export async function createRoutesFile( for (const page of pages) { if (page.pathname === '404') hasPrerendered404 = true; const pageSegments = removeLeadingForwardSlash(page.pathname) - .split(posix.sep) + .split(path.posix.sep) .filter(Boolean) .map((s) => { return getParts(s);