mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix(dependency-path)!: escape # character in directory name (#8557)
This commit is contained in:
7
.changeset/violet-rockets-pull.md
Normal file
7
.changeset/violet-rockets-pull.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/dependency-path": major
|
||||
"@pnpm/core": major
|
||||
pnpm: major
|
||||
---
|
||||
|
||||
Escape the `#` character in directory names within the virtual store (`node_modules/.pnpm`) [#8557](https://github.com/pnpm/pnpm/pull/8557).
|
||||
@@ -165,7 +165,7 @@ export function parse (dependencyPath: string): DependencyPath {
|
||||
}
|
||||
|
||||
export function depPathToFilename (depPath: string, maxLengthWithoutHash: number): string {
|
||||
let filename = depPathToFilenameUnescaped(depPath).replace(/[\\/:*?"<>|]/g, '+')
|
||||
let filename = depPathToFilenameUnescaped(depPath).replace(/[\\/:*?"<>|#]/g, '+')
|
||||
if (filename.includes('(')) {
|
||||
filename = filename
|
||||
.replace(/\)$/, '')
|
||||
|
||||
@@ -98,6 +98,9 @@ test('depPathToFilename()', () => {
|
||||
|
||||
expect(depPathToFilename('abcd/'.repeat(200), 120)).toBe('abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+abcd+ab_e7c10c3598ebbc0ca640b6524c68e602') // cspell:disable-line
|
||||
expect(depPathToFilename('/JSONSteam@1.0.0', 120)).toBe('JSONSteam@1.0.0_533d3b11e9111b7a24f914844c021ddf') // cspell:disable-line
|
||||
|
||||
expect(depPathToFilename('foo@git+https://github.com/something/foo#1234', 120)).toBe('foo@git+https+++github.com+something+foo+1234')
|
||||
expect(depPathToFilename('foo@https://codeload.github.com/something/foo/tar.gz/1234#path:packages/foo', 120)).toBe('foo@https+++codeload.github.com+something+foo+tar.gz+1234+path+packages+foo')
|
||||
})
|
||||
|
||||
test('tryGetPackageId', () => {
|
||||
|
||||
@@ -339,3 +339,14 @@ test('from subdirectories of a git repo', async () => {
|
||||
'@my-namespace/simple-react-app': 'github:RexSkz/test-git-subfolder-fetch#path:/packages/simple-react-app',
|
||||
})
|
||||
})
|
||||
|
||||
test('no hash character for github subdirectory install', async () => {
|
||||
prepareEmpty()
|
||||
|
||||
await addDependenciesToPackage({}, [
|
||||
'github:pnpm/only-allow#path:/&v1.2.1',
|
||||
], testDefaults())
|
||||
|
||||
expect(fs.readdirSync('./node_modules/.pnpm'))
|
||||
.toContain('only-allow@https+++codeload.github.com+pnpm+only-allow+tar.gz+4d577a5a5862a43e752df37a1e8a0c71c3a0084a+path++')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user