mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-31 13:32:18 -04:00
5
.changeset/early-pumpkins-smoke.md
Normal file
5
.changeset/early-pumpkins-smoke.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/tarball-resolver": patch
|
||||
---
|
||||
|
||||
Ignore URLs to repositories.
|
||||
@@ -26,6 +26,16 @@ test('from a github repo', async (t: tape.Test) => {
|
||||
t.deepEqual(manifest.dependencies, { 'is-negative': 'github:kevva/is-negative' }, 'has been added to dependencies in package.json')
|
||||
})
|
||||
|
||||
test('from a github repo through URL', async (t: tape.Test) => {
|
||||
const project = prepareEmpty(t)
|
||||
|
||||
const manifest = await addDependenciesToPackage({}, ['https://github.com/kevva/is-negative'], await testDefaults())
|
||||
|
||||
await project.has('is-negative')
|
||||
|
||||
t.deepEqual(manifest.dependencies, { 'is-negative': 'github:kevva/is-negative' }, 'has been added to dependencies in package.json')
|
||||
})
|
||||
|
||||
test('from a github repo with different name via named installation', async (t: tape.Test) => {
|
||||
const project = prepareEmpty(t)
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ export default async function resolveTarball (
|
||||
return null
|
||||
}
|
||||
|
||||
if (isRepository(wantedDependency.pref)) return null
|
||||
|
||||
return {
|
||||
id: `@${wantedDependency.pref.replace(/^.*:\/\/(git@)?/, '')}`,
|
||||
normalizedPref: wantedDependency.pref,
|
||||
@@ -16,3 +18,17 @@ export default async function resolveTarball (
|
||||
resolvedVia: 'url',
|
||||
}
|
||||
}
|
||||
|
||||
const GIT_HOSTERS = new Set([
|
||||
'github.com',
|
||||
'gitlab.com',
|
||||
'bitbucket.org',
|
||||
])
|
||||
|
||||
function isRepository (pref: string) {
|
||||
if (pref.endsWith('/')) {
|
||||
pref = pref.substr(0, pref.length - 1)
|
||||
}
|
||||
const parts = pref.split('/')
|
||||
return (parts.length === 5 && GIT_HOSTERS.has(parts[2]))
|
||||
}
|
||||
|
||||
@@ -46,3 +46,11 @@ test('tarballs from GitHub (is-negative)', async t => {
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('ignore direct URLs to repositories', async t => {
|
||||
t.equal(await resolveFromTarball({ pref: 'https://github.com/foo/bar' }), null)
|
||||
t.equal(await resolveFromTarball({ pref: 'https://github.com/foo/bar/' }), null)
|
||||
t.equal(await resolveFromTarball({ pref: 'https://gitlab.com/foo/bar' }), null)
|
||||
t.equal(await resolveFromTarball({ pref: 'https://bitbucket.org/foo/bar' }), null)
|
||||
t.end()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user