npm-registry-fetch
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="3.5.0"></a> | ||
# [3.5.0](https://github.com/npm/registry-fetch/compare/v3.4.0...v3.5.0) (2018-08-22) | ||
### Features | ||
* **pkgid:** heuristic pkgid calculation for errors ([2e789a5](https://github.com/npm/registry-fetch/commit/2e789a5)) | ||
<a name="3.4.0"></a> | ||
@@ -7,0 +17,0 @@ # [3.4.0](https://github.com/npm/registry-fetch/compare/v3.3.0...v3.4.0) (2018-08-22) |
'use strict' | ||
const url = require('url') | ||
function packageName (href) { | ||
try { | ||
let basePath = url.parse(href).pathname.substr(1) | ||
if (!basePath.match(/^-/)) { | ||
basePath = basePath.split('/') | ||
var index = basePath.indexOf('_rewrite') | ||
if (index === -1) { | ||
index = basePath.length - 1 | ||
} else { | ||
index++ | ||
} | ||
return decodeURIComponent(basePath[index]) | ||
} | ||
} catch (_) { | ||
// this is ok | ||
} | ||
} | ||
class HttpErrorBase extends Error { | ||
@@ -12,2 +32,3 @@ constructor (method, res, body, spec) { | ||
this.body = body | ||
this.pkgid = spec ? spec.toString() : packageName(res.url) | ||
} | ||
@@ -14,0 +35,0 @@ } |
{ | ||
"name": "npm-registry-fetch", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "Fetch-based http client for use with npm registry APIs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38231
489