Skip to content

Commit

Permalink
Fixes a bug in how injectRoute parses route patterns on Windows (#3763
Browse files Browse the repository at this point in the history
)

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

* chore: add changeset
  • Loading branch information
Tony Sullivan authored Jun 29, 2022
1 parent 40be96d commit 54cd6b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/seven-rocks-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes how `injectRoute` parses route patterns on Windows
3 changes: 2 additions & 1 deletion packages/astro/src/core/routing/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 54cd6b8

Please sign in to comment.