npm version: accurate information using Accept header.

See <https://github.com/npm/npmjs.org/issues/163>.
This commit is contained in:
Thaddee Tyl 2014-03-19 12:23:11 +01:00
parent 893dc41807
commit 8ce49b9196

View File

@ -288,7 +288,9 @@ cache(function(data, match, sendBadge) {
var format = match[2];
var apiUrl = 'https://registry.npmjs.org/' + repo + '/latest';
var badgeData = getBadgeData('npm', data);
request(apiUrl, function(err, res, buffer) {
// Using the Accept header because of this bug:
// <https://github.com/npm/npmjs.org/issues/163>
request(apiUrl, { headers: { 'Accept': '*/*' } }, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);