fix(http.request): Cast URL to string before sending it to NodeJS core (#1378)

* Add some jsdoc

* cast url to string before sending it to NodeJS core
This commit is contained in:
Jimmy Wärting 2021-11-12 12:37:51 +01:00 committed by GitHub
parent 3f0e0c2949
commit 0284826de6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -78,7 +78,7 @@ export default async function fetch(url, options_) {
};
// Send request
const request_ = send(parsedURL, options);
const request_ = send(parsedURL.toString(), options);
if (signal) {
signal.addEventListener('abort', abortAndFinalize);

View File

@ -1,4 +1,3 @@
/**
* Request.js
*
@ -21,7 +20,7 @@ const INTERNALS = Symbol('Request internals');
/**
* Check if `obj` is an instance of Request.
*
* @param {*} obj
* @param {*} object
* @return {boolean}
*/
const isRequest = object => {
@ -133,14 +132,17 @@ export default class Request extends Body {
this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || '';
}
/** @returns {string} */
get method() {
return this[INTERNALS].method;
}
/** @returns {string} */
get url() {
return formatUrl(this[INTERNALS].parsedURL);
}
/** @returns {Headers} */
get headers() {
return this[INTERNALS].headers;
}
@ -149,6 +151,7 @@ export default class Request extends Body {
return this[INTERNALS].redirect;
}
/** @returns {AbortSignal} */
get signal() {
return this[INTERNALS].signal;
}
@ -206,8 +209,8 @@ Object.defineProperties(Request.prototype, {
/**
* Convert a Request to Node.js http request options.
*
* @param Request A Request instance
* @return Object The options object to be passed to http.request
* @param {Request} request - A Request instance
* @return The options object to be passed to http.request
*/
export const getNodeRequestOptions = request => {
const {parsedURL} = request[INTERNALS];
@ -296,6 +299,7 @@ export const getNodeRequestOptions = request => {
};
return {
/** @type {URL} */
parsedURL,
options
};