Skip to content

fix(routing): normalize path.relative() results for Windows compat#2547

Open
hiro-nikaitou wants to merge 3 commits into
cloudflare:mainfrom
hiro-nikaitou:fix/windows-path-normalization
Open

fix(routing): normalize path.relative() results for Windows compat#2547
hiro-nikaitou wants to merge 3 commits into
cloudflare:mainfrom
hiro-nikaitou:fix/windows-path-normalization

Conversation

@hiro-nikaitou

Copy link
Copy Markdown

Problem

Windows Node.js path.relative() and path.join() return backslash paths. Vite normalizes all paths to forward slashes. Without normalization, Windows users hit cache misses and failed route lookups.

Prior PRs #1578 (StaticFileCache) and #1604 (normalizePathSeparators utility) addressed the first cases. This extends normalization to all remaining sites in the route graph builder.

Changes

All in packages/vinext/src/routing/app-route-graph.ts:

  • findSlotSubPages: wrap path.relative() with normalizePathSeparators()
  • Both consumers: use "/" split (input now forward-slash)
  • findSlotConfigLayoutTreePositions: normalize + "/" split
  • computeLayoutTreePositions: normalize + "/" split

Verification

Closes #1605.

# Resolved conflict: computeLayoutTreePositions - keep upstream's
# robust empty-string check (handles mixed separators on win32)
# while applying normalizePathSeparators and '/' split from PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalize internal paths to forward slashes for Windows support

1 participant