Skip to content

Commit

Permalink
Added windows support for static file path splitting (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
veitbjarsch authored Sep 17, 2024
1 parent 72a580f commit 04e5c38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-steaks-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---

Fixes a bug which was caused on windows when splitting static file paths
6 changes: 3 additions & 3 deletions packages/cloudflare/src/utils/generate-routes-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 04e5c38

Please sign in to comment.