fix: escape a colon in tarbal dependency ID (#3183)

close #3182
This commit is contained in:
Zoltan Kochan
2021-02-22 11:21:27 +02:00
committed by Zoltan Kochan
parent 08039f3870
commit 992820161c
3 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/tarball-resolver": patch
---
The ID of a tarball dependency should not contain colons, when the URL has a port. The colon should be escaped with a plus sign.

View File

@@ -10,7 +10,7 @@ export default async function resolveTarball (
if (isRepository(wantedDependency.pref)) return null
return {
id: `@${wantedDependency.pref.replace(/^.*:\/\/(git@)?/, '')}`,
id: `@${wantedDependency.pref.replace(/^.*:\/\/(git@)?/, '').replace(':', '+')}`,
normalizedPref: wantedDependency.pref,
resolution: {
tarball: wantedDependency.pref,

View File

@@ -14,6 +14,19 @@ test('tarball from npm registry', async () => {
})
})
test('tarball from URL that contain port number', async () => {
const resolutionResult = await resolveFromTarball({ pref: 'http://buildserver.mycompany.com:81/my-private-package-0.1.6.tgz' })
expect(resolutionResult).toStrictEqual({
id: '@buildserver.mycompany.com+81/my-private-package-0.1.6.tgz',
normalizedPref: 'http://buildserver.mycompany.com:81/my-private-package-0.1.6.tgz',
resolution: {
tarball: 'http://buildserver.mycompany.com:81/my-private-package-0.1.6.tgz',
},
resolvedVia: 'url',
})
})
test('tarball not from npm registry', async () => {
const resolutionResult = await resolveFromTarball({ pref: 'https://github.com/hegemonic/taffydb/tarball/master' })