From 54cd6b8dd184fb0acb2facaa9b6843be59f9c57f Mon Sep 17 00:00:00 2001 From: Tony Sullivan Date: Wed, 29 Jun 2022 14:46:23 +0000 Subject: [PATCH] Fixes a bug in how `injectRoute` parses route patterns on Windows (#3763) * always remove a leading slash in the `injectRoute` pattern * chore: add changeset --- .changeset/seven-rocks-sort.md | 5 +++++ packages/astro/src/core/routing/manifest/create.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/seven-rocks-sort.md diff --git a/.changeset/seven-rocks-sort.md b/.changeset/seven-rocks-sort.md new file mode 100644 index 000000000000..32b4a25acda1 --- /dev/null +++ b/.changeset/seven-rocks-sort.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes how `injectRoute` parses route patterns on Windows diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index 053624961681..ba40f3b1b263 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -7,6 +7,7 @@ import path from 'path'; import slash from 'slash'; import { fileURLToPath } from 'url'; import { warn } from '../../logger/core.js'; +import { removeLeadingForwardSlash } from '../../path.js'; import { resolvePages } from '../../util.js'; import { getRouteGenerator } from './generator.js'; const require = createRequire(import.meta.url); @@ -294,7 +295,7 @@ export function createRouteManifest( const isDynamic = (str: string) => str?.[0] === '['; const normalize = (str: string) => str?.substring(1, str?.length - 1); - const segments = name + const segments = removeLeadingForwardSlash(name) .split(path.sep) .filter(Boolean) .map((s: string) => {