Fixes a bug in how injectRoute parses route patterns on Windows (#3763)

* always remove a leading slash in the `injectRoute` pattern

* chore: add changeset
This commit is contained in:
Tony Sullivan 2022-06-29 14:46:23 +00:00 committed by GitHub
parent 40be96d7c8
commit 54cd6b8dd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes how `injectRoute` parses route patterns on Windows

View file

@ -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) => {