Skip to content

Conversation

ntkme
Copy link
Contributor

@ntkme ntkme commented Dec 10, 2024

Node recently changed what is escaped and what is not in pathToFileURL, causing tests to fail on node 22 LTS and higher:
nodejs/node#54545

@ntkme ntkme force-pushed the update-path-to-file-url branch from d63f98e to e11a1e7 Compare December 10, 2024 19:17
lib/src/utils.ts Outdated
}

if (process.platform === 'win32') {
fileUrl = fileUrl.replace(/%5C/g, '/').replace(/\\/g, '/');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changing the behavior even for previous Node versions. Previously we always replaced backslash with forward slash, now we're only doing it on Windows. Is that intentional?

Copy link
Contributor Author

@ntkme ntkme Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. fileURLToPath on linux has \ escaped as %5C, and in the previous implementation you can see that only on windows it's reverting the escape of %5C, meaning .replace(/\\/g, '/') on linux actually did nothing.

Copy link
Contributor Author

@ntkme ntkme Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, .replace(/\\/g, '/') seems to be unnecessary, as I'm now replacing %5C (backslash) directly with / (forward slash).

@nex3 nex3 merged commit 5a10661 into sass:main Dec 12, 2024
17 checks passed
@ntkme ntkme deleted the update-path-to-file-url branch December 12, 2024 01:55
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.

2 participants