add support for relative urls

This commit is contained in:
ading2210 2024-04-30 13:22:47 -04:00
parent 294fbd65f3
commit 8ac0f40896
4 changed files with 23 additions and 4 deletions

View file

@ -2,6 +2,7 @@ class HTTPSession extends CurlSession {
constructor(options={}) {
super();
this.options = options;
this.base_url = undefined;
this.set_connections(50, 40);
this.import_cookies();
@ -90,6 +91,9 @@ class HTTPSession extends CurlSession {
params.headers = params.headers || Object.fromEntries(resource.headers);
params.method = params.method || resource.method;
}
else {
url = (new URL(url, this.base_url)).href;
}
let body = await this.constructor.create_options(params);
return await this.request_async(url, params, body);
}