Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added windows support for static files #387

Merged
merged 8 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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