Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ! jsDelivr can response with 403 Forbidden, if over 50MB
if (err.response && err.response.status === 403) {
try {
// ! so, try through UNPKG.com
pkg = await packageJson(
packageName,
(x, t) => `https://unpkg.com/${x}@${t}/package.json`,
);
} catch (error) {
throw new ky.HTTPError(
`Package "${name}" not found, even through UNPKG.com!`,
);
}
return pkg;
}
throw new ky.HTTPError(`Package "${name}" not found or loading error!`);
}
return pkg;
}
try {
if (isJsonResponse(response)) {
const data = await response.json()
log(data)
msg = data.Message || data.message
} else {
msg = await response.text()
}
} catch (err) {
log('Failed to parse error response', err)
// Failed to extract/parse error message from response
msg = err.message
}
const error = new HTTPError(response)
// If we managed to extract a message from the response, use it
if (msg) {
error.message = msg
}
throw error
}
try {
pkg = await ky
.get(uri)
.then((resp) => resp.text())
.then(JSON.parse);
} catch (err) {
// ! jsDelivr can response with 403 Forbidden, if over 50MB
if (err.response && err.response.status === 403) {
try {
// ! so, try through UNPKG.com
pkg = await packageJson(
packageName,
(x, t) => `https://unpkg.com/${x}@${t}/package.json`,
);
} catch (error) {
throw new ky.HTTPError(
`Package "${name}" not found, even through UNPKG.com!`,
);
}
return pkg;
}
throw new ky.HTTPError(`Package "${name}" not found or loading error!`);
}
return pkg;
}