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:
parent
40be96d7c8
commit
54cd6b8dd1
2 changed files with 7 additions and 1 deletions
5
.changeset/seven-rocks-sort.md
Normal file
5
.changeset/seven-rocks-sort.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes how `injectRoute` parses route patterns on Windows
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue