mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
6
.changeset/hot-hairs-thank.md
Normal file
6
.changeset/hot-hairs-thank.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"dependency-path": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Sanitize the directory names created inside `node_modules/.pnpm` and inside the global store [#4716](https://github.com/pnpm/pnpm/issues/4716)
|
||||
@@ -131,7 +131,7 @@ export function parse (dependencyPath: string) {
|
||||
}
|
||||
|
||||
export function depPathToFilename (depPath: string) {
|
||||
const filename = depPathToFilenameUnescaped(depPath).replace(/\//g, '+')
|
||||
const filename = depPathToFilenameUnescaped(depPath).replace(/[\\/:*?"<>|]/g, '+')
|
||||
if (filename.length > 120 || filename !== filename.toLowerCase() && !filename.startsWith('file+')) {
|
||||
return `${filename.substring(0, 50)}_${createBase32Hash(filename)}`
|
||||
}
|
||||
|
||||
@@ -130,7 +130,8 @@ test('resolve()', () => {
|
||||
test('depPathToFilename()', () => {
|
||||
expect(depPathToFilename('/foo/1.0.0')).toBe('foo@1.0.0')
|
||||
expect(depPathToFilename('/@foo/bar/1.0.0')).toBe('@foo+bar@1.0.0')
|
||||
expect(depPathToFilename('github.com/something/foo/0000')).toBe('github.com+something+foo@0000')
|
||||
expect(depPathToFilename('github.com/something/foo/0000?v=1')).toBe('github.com+something+foo@0000+v=1')
|
||||
expect(depPathToFilename('\\//:*?"<>|')).toBe('++@+++++++')
|
||||
|
||||
const filename = depPathToFilename('file:test/foo-1.0.0.tgz_foo@2.0.0')
|
||||
expect(filename).toBe('file+test+foo-1.0.0.tgz_foo@2.0.0')
|
||||
|
||||
Reference in New Issue
Block a user