From a91329c1e075fa518273abf858a61620f0db53f4 Mon Sep 17 00:00:00 2001 From: Dan Gautsch Date: Fri, 31 Aug 2018 10:42:31 -0400 Subject: [PATCH] Fix/129 - Packages 404 (#130) * Checking response body from npm then parsing as necessary Fix #129 --- lib/npm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/npm.js b/lib/npm.js index c3f6f9c..60a957d 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -65,7 +65,7 @@ async function get (name, etag) { let pkg = redis ? await fetchFromCache(name) : null if (pkg) return pkg let req = await HTTP.request(url.resolve(config.uplink.href, '/' + name.replace(/\//, '%2F')), getRequestOpts(etag)) - pkg = req.body + pkg = typeof req.body === 'string' ? JSON.parse(req.body) : req.body if (!pkg.versions) return 404 pkg.etag = req.response.headers.etag updateCache(pkg)