npm-registry-fetch
Advanced tools
Comparing version 17.0.0 to 17.0.1
'use strict' | ||
const url = require('url') | ||
const { URL } = require('node:url') | ||
function packageName (href) { | ||
try { | ||
let basePath = new url.URL(href).pathname.slice(1) | ||
let basePath = new URL(href).pathname.slice(1) | ||
if (!basePath.match(/^-/)) { | ||
@@ -18,3 +18,3 @@ basePath = basePath.split('/') | ||
} | ||
} catch (_) { | ||
} catch { | ||
// this is ok | ||
@@ -28,3 +28,3 @@ } | ||
this.name = this.constructor.name | ||
this.headers = res.headers.raw() | ||
this.headers = typeof res.headers?.raw === 'function' ? res.headers.raw() : res.headers | ||
this.statusCode = res.status | ||
@@ -36,5 +36,5 @@ this.code = `E${res.status}` | ||
this.pkgid = spec ? spec.toString() : packageName(res.url) | ||
Error.captureStackTrace(this, this.constructor) | ||
} | ||
} | ||
module.exports.HttpErrorBase = HttpErrorBase | ||
@@ -51,6 +51,4 @@ class HttpErrorGeneral extends HttpErrorBase { | ||
}` | ||
Error.captureStackTrace(this, HttpErrorGeneral) | ||
} | ||
} | ||
module.exports.HttpErrorGeneral = HttpErrorGeneral | ||
@@ -62,6 +60,4 @@ class HttpErrorAuthOTP extends HttpErrorBase { | ||
this.code = 'EOTP' | ||
Error.captureStackTrace(this, HttpErrorAuthOTP) | ||
} | ||
} | ||
module.exports.HttpErrorAuthOTP = HttpErrorAuthOTP | ||
@@ -73,6 +69,4 @@ class HttpErrorAuthIPAddress extends HttpErrorBase { | ||
this.code = 'EAUTHIP' | ||
Error.captureStackTrace(this, HttpErrorAuthIPAddress) | ||
} | ||
} | ||
module.exports.HttpErrorAuthIPAddress = HttpErrorAuthIPAddress | ||
@@ -83,5 +77,11 @@ class HttpErrorAuthUnknown extends HttpErrorBase { | ||
this.message = 'Unable to authenticate, need: ' + res.headers.get('www-authenticate') | ||
Error.captureStackTrace(this, HttpErrorAuthUnknown) | ||
} | ||
} | ||
module.exports.HttpErrorAuthUnknown = HttpErrorAuthUnknown | ||
module.exports = { | ||
HttpErrorBase, | ||
HttpErrorGeneral, | ||
HttpErrorAuthOTP, | ||
HttpErrorAuthIPAddress, | ||
HttpErrorAuthUnknown, | ||
} |
{ | ||
"name": "npm-registry-fetch", | ||
"version": "17.0.0", | ||
"version": "17.0.1", | ||
"description": "Fetch-based http client for use with npm registry APIs", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
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
38857
566