mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
esm: throw on any non-2xx response
Treat redirects without Location and other 3xx responses as errors PR-URL: https://github.com/nodejs/node/pull/43742 Refs: https://github.com/nodejs/node/pull/43689 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
This commit is contained in:
1 parent
f28198cc05
commit
9b5b8d78c3
1 file changed
+3
-1
@@ -148,7 +148,9 @@ function fetchWithRedirects(parsed) {
|
||||
err.message = `Cannot find module '${parsed.href}', HTTP 404`;
|
||||
throw err;
|
||||
}
|
||||
if (res.statusCode < 200 || res.statusCode >= 400) {
|
||||
// This condition catches all unsupported status codes, including
|
||||
// 3xx redirection codes without `Location` HTTP header.
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
throw new ERR_NETWORK_IMPORT_DISALLOWED(
|
||||
res.headers.location,
|
||||
parsed.href,
|
||||
|
||||
Reference in new issue
Block a user