This repository was archived by the owner on Dec 22, 2025. It is now read-only.
Fix Windows path issues with URL pathname handling #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Warning : This is a Copilot PR that I tested and it works. A bit verbose but the core is here
Problem
The integration was failing on Windows with
ENOENTerrors due to incorrect path handling:The root cause was improper handling of file URLs on Windows. When Astro passes configuration URLs like
file:///C:/Users/..., theURL.pathnameproperty returns/C:/Users/...(with a leading slash). Using this directly withpath.join()created invalid paths likeC:\C:\Users\..., doubling the drive letter.Solution
Implemented proper URL-to-path conversion using Node.js's built-in
fileURLToPath()function from theurlmodule. This function correctly handles the conversion on all platforms:file:///C:/Users/test→C:\Users\testfile:///home/user/test→/home/user/testChanges
Cache initialization - Fixed path construction when creating the cache directory:
Directory traversal - Fixed path handling in the
traverseDirectoryfunction:Error handling - Added try-catch blocks and checks for broken symlinks to prevent crashes when encountering inaccessible directories.
Testing