npm / minipass-fetch

An implementation of window.fetch in Node.js using Minipass streams
Other
54 stars 11 forks source link

do not lose extra opts when input is an object #9

Closed nlf closed 3 years ago

nlf commented 3 years ago

in make-fetch-happen we construct a request object and then pass it as the only parameter to fetch, like

const req = new fetch.Request(uri, opts)
return fetch(req)

the current behavior of this module will extract some properties from the request object, but not all, which causes things like the rejectUnauthorized, ca, cert, key, etc options to be dropped when the actual request is sent.

in addition, the current behavior is such that if input was an object, but that object doesn't contain an href property, we would drop the entire object in favor of an empty one.

the changes here will allow the above usage to work as intended, as well as being more intuitive when passing input as an object.

References

Related to https://github.com/npm/cli/issues/1700