Skip to content

Commit

Permalink
update to referer-less npm-registry-fetch
Browse files Browse the repository at this point in the history
Depends on npm/npm-registry-fetch#25

Land that PR before merging this commit.
  • Loading branch information
isaacs committed Feb 24, 2020
1 parent 4545243 commit 094623e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/remote.js
Expand Up @@ -51,6 +51,7 @@ class RemoteFetcher extends Fetcher {
'pacote-pkg-id': this.pkgid,
...(this.integrity ? { 'pacote-integrity': String(this.integrity) }
: {}),
...(this.opts.headers || {}),
}
}

Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -46,7 +46,7 @@
"npm-package-arg": "^8.0.0",
"npm-packlist": "^2.1.0",
"npm-pick-manifest": "^6.0.0",
"npm-registry-fetch": "^7.0.1",
"npm-registry-fetch": "github:npm/npm-registry-fetch#isaacs/no-referer",
"osenv": "^0.1.5",
"promise-inflight": "^1.0.1",
"promise-retry": "^1.1.1",
Expand Down
20 changes: 14 additions & 6 deletions test/remote.js
Expand Up @@ -52,14 +52,21 @@ t.test('start server', t => {
t.test('packument', t => {
//const url = 'https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz'
const url = `${server}/abbrev.tgz`
const f = new RemoteFetcher(url, { cache })
const f = new RemoteFetcher(url, {
cache,
preferOffline: true,
headers: {
'not-referer': 'http://example.com',
},
projectScope: '@npmcli',
npmSession: 'foobarbaz',
})
// run twice to pull from cache the second time
return t.resolveMatchSnapshot(f.packument(), 'packument')
.then(() => {
const f2 = new RemoteFetcher(`abbrev@${url}`, {
cache,
pkgid: `remote:abbrev@${url}`,
preferOffline: true,
cache,
})
return t.resolveMatchSnapshot(f2.packument(), 'packument 2')
})
Expand All @@ -72,15 +79,16 @@ t.test('packument', t => {
{
connection: 'keep-alive',
'user-agent': `pacote/${version} node/${process.version}`,
'npm-scope': 'undefined',
'npm-session': 'undefined',
referer: 'undefined',
'pacote-version': version,
'pacote-req-type': 'tarball',
'pacote-pkg-id': `remote:${server}/abbrev.tgz`,
accept: '*/*',
'accept-encoding': 'gzip,deflate',
host: require('url').parse(server).host,
'npm-session': 'foobarbaz',
'npm-scope': '@npmcli',
'npm-in-ci': String,
'not-referer': 'http://example.com',
}
]
])
Expand Down

0 comments on commit 094623e

Please sign in to comment.