Deno: new Request(...) ignores url property

Created on 6 Oct 2020  路  6Comments  路  Source: denoland/deno

> new Request(undefined, { url: "https://deno.land/" });
Request {
  _bodySource: "",
  _stream: null,
  headers: Headers {},
  method: "GET",
  url: "",              // <- WRONG
  credentials: "omit"
}

https://github.com/denoland/deno/blob/6b8aef5103e6c77cc89ae4c7da959b39b1c4af4a/op_crates/fetch/26_fetch.js#L973-L974

bug invalid web

All 6 comments

Apologies, I retract this bug report. I believe the real bug is that new Request(undefined) should throw an "invalid URL" TypeError.

In ~browsers~ Chrome, the undefined gets stringified. Seems easier.

FWIW, Firefox 81.0.1 throws an "undefined is not a valid URL" TypeError.

In browsers Chrome, the undefined gets stringified. Seems easier.

That sounds like a Chrome bug:

https://fetch.spec.whatwg.org/#dom-request says first param may be a string, otherwise it must be asserted to be a Request object. I assume that means throw a TypeError if it is not one of the two.

FWIW, Firefox 81.0.1 throws an "undefined is not a valid URL" TypeError.

Actually can't reproduce on 81.0. For me it does the same as Chrome (which does the same as Safari)

So it seems the stringified undefined is intended behavior:

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doutchnugget picture doutchnugget  路  3Comments

watilde picture watilde  路  3Comments

davidbarratt picture davidbarratt  路  3Comments

somombo picture somombo  路  3Comments

JosephAkayesi picture JosephAkayesi  路  3Comments