From b7165476fa8fcefec7648453ad1ac91ead63f934 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 7 Mar 2020 15:39:18 -0800 Subject: [PATCH] Remove HTTP Referer header config Last bit of https://github.com/npm/cli/issues/930 --- lib/npm.js | 18 ------------------ test/tap/referer.js | 23 ----------------------- 2 files changed, 41 deletions(-) delete mode 100644 test/tap/referer.js diff --git a/lib/npm.js b/lib/npm.js index 22b7b4f40a53e..03b333867ab5c 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -103,8 +103,6 @@ return littleGuys.indexOf(c) === -1 }) - var registryRefer - Object.keys(abbrevs).concat(plumbing).forEach(function addCommand (c) { Object.defineProperty(npm.commands, c, { get: function () { if (!loaded) { @@ -140,22 +138,6 @@ } }) - if (!registryRefer) { - registryRefer = [a].concat(args[0]).map(function (arg) { - // exclude anything that might be a URL, path, or private module - // Those things will always have a slash in them somewhere - if (arg && arg.match && arg.match(/\/|\\/)) { - return '[REDACTED]' - } else { - return arg - } - }).filter(function (arg) { - return arg && arg.match - }).join(' ') - npm.referer = registryRefer - npm.config.set('refer', npm.referer) - } - cmd.apply(npm, args) } diff --git a/test/tap/referer.js b/test/tap/referer.js deleted file mode 100644 index 8c3dbed72c319..0000000000000 --- a/test/tap/referer.js +++ /dev/null @@ -1,23 +0,0 @@ -var common = require('../common-tap.js') -var test = require('tap').test -var http = require('http') - -test('should send referer http header', function (t) { - http.createServer(function (q, s) { - t.equal(q.headers.referer, 'install foo') - s.statusCode = 404 - s.end(JSON.stringify({error: 'whatever'})) - this.close() - }).listen(common.port, function () { - var reg = 'http://localhost:' + common.port - var args = [ 'install', 'foo', '--registry', reg ] - common.npm(args, {}, function (er, code) { - if (er) { - throw er - } - // should not have ended nicely, since we returned an error - t.ok(code) - t.end() - }) - }) -})