Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/violet-rockets-pull.md
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 1 addition & 1 deletion packages/dependency-path/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(/\)$/, '')
Expand Down
3 changes: 3 additions & 0 deletions packages/dependency-path/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('/[email protected]', 120)).toBe('[email protected]_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', () => {
Expand Down
11 changes: 11 additions & 0 deletions pkg-manager/core/test/install/fromRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++')
})
Loading