diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-07-06 03:37:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-05 21:37:18 -0400 |
commit | 3b4260dc54237070e28f31e6253f3fa125153638 (patch) | |
tree | cee70005c11e9e03315ae1c8eb80fd6d64c0908f /cli/js/web/fetch.ts | |
parent | 5b09e721d3a390bbe79ac0403ab0670faeb12823 (diff) |
fix(cli/fetch): response constructor default properties (#6650)
Diffstat (limited to 'cli/js/web/fetch.ts')
-rw-r--r-- | cli/js/web/fetch.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cli/js/web/fetch.ts b/cli/js/web/fetch.ts index 045d1afcd..0c419178a 100644 --- a/cli/js/web/fetch.ts +++ b/cli/js/web/fetch.ts @@ -34,14 +34,14 @@ export class Response extends Body.Body implements domTypes.Response { const extraInit = responseData.get(init) || {}; let { type = "default", url = "" } = extraInit; - let status = (Number(init.status) || 0) ?? 200; + let status = init.status === undefined ? 200 : Number(init.status || 0); let statusText = init.statusText ?? ""; let headers = init.headers instanceof Headers ? init.headers : new Headers(init.headers); - if (init.status && (status < 200 || status > 599)) { + if (init.status !== undefined && (status < 200 || status > 599)) { throw new RangeError( `The status provided (${init.status}) is outside the range [200, 599]` ); @@ -117,7 +117,7 @@ export class Response extends Body.Body implements domTypes.Response { this.statusText = statusText; this.status = extraInit.status || status; this.headers = headers; - this.redirected = extraInit.redirected; + this.redirected = extraInit.redirected || false; this.type = type; } |