Skip to content

fix(arborist): normalize file and directory paths in allowScripts matcher - #9906

Open
anasysuf wants to merge 1 commit into
npm:latestfrom
anasysuf:fix/allow-scripts-windows-file-match
Open

fix(arborist): normalize file and directory paths in allowScripts matcher#9906
anasysuf wants to merge 1 commit into
npm:latestfrom
anasysuf:fix/allow-scripts-windows-file-match

Conversation

@anasysuf

Copy link
Copy Markdown

Description

Fixes an issue on Windows where allowScripts failed to match local tarball / file dependencies (file:C:\... vs file:C:/...).

npa(key) normalizes saveSpec to forward slashes, whereas consistentResolve on Windows produces backslashes in node.resolved. Furthermore, fetchSpec strips the file: prefix. This PR normalizes file/directory paths (converting backslashes to forward slashes and stripping optional file: prefixes for comparison) in script-allowed.js and allow-scripts-writer.js.

Fixes #9900

Testing

  • Added unit tests in workspaces/arborist/test/script-allowed.js covering Windows backslash, forward slash, and drive-letter file paths.
  • Verified all unit tests in @npmcli/arborist and allow-scripts-writer pass.

@anasysuf
anasysuf requested review from a team as code owners August 21, 2026 15:15
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.

[BUG] allowScripts does not work for local tarball on Windows

1 participant