From 90b8427a308e2b27f76d7ebb454e27abbd745df7 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 1 May 2014 16:12:09 -0700 Subject: send referer header --- lib/npm.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/npm.js') diff --git a/lib/npm.js b/lib/npm.js index a529862d5..c8965bdc6 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -191,20 +191,38 @@ Object.keys(abbrevs).concat(plumbing).forEach(function addCommand (c) { if (c === "la" || c === "ll") { npm.config.set("long", true) } + npm.command = c if (commandCache[a]) return commandCache[a] + var cmd = require(__dirname+"/"+a+".js") + commandCache[a] = function () { var args = Array.prototype.slice.call(arguments, 0) if (typeof args[args.length - 1] !== "function") { args.push(defaultCb) } if (args.length === 1) args.unshift([]) + + npm.registry.refer = [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(/\/|\\/)) { + return "[REDACTED]" + } else { + return arg + } + }).filter(function (arg) { + return arg + }).join(" ") + cmd.apply(npm, args) } + Object.keys(cmd).forEach(function (k) { commandCache[a][k] = cmd[k] }) + return commandCache[a] }, enumerable: fullList.indexOf(c) !== -1 }) -- cgit v1.2.3