Skip to content

Commit

Permalink
fix: npm.org now has a different way to request info about scoped pac…
Browse files Browse the repository at this point in the history
…kages: via the `Npm-Scope` header. See also https://docs.npmjs.com/misc/registry
  • Loading branch information
GerHobbelt committed Oct 3, 2017
1 parent 3ee4982 commit 368495e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/datasrc/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@ var repo = '';
function packageHistory(moduleName) {
var deferred = q.defer();
// Escape / in moduleName to support scoped repositories
var url = 'http://registry.npmjs.org/' + moduleName.replace('/', '%2F');
var url = 'http://registry.npmjs.org/' + moduleName.replace(/^@[^/]+\//, '');
log.debug('requesting: ' + url);

request({ uri: url, json: true }, function (err, res, data) {
var query = {
uri: url,
json: true
};
var packageScope = moduleName.replace(/^@([^/]+)\/[^/]+$/, '$1');
log.debug('scoped package? scope = ' + (packageScope ? packageScope : '(none)'));
if (packageScope) {
query.headers = {
"Npm-Scope": packageScope
};
}
request(query, function (err, res, data) {
log.debug('complete: ' + url);

if (err) {
Expand Down

0 comments on commit 368495e

Please sign in to comment.