mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
add support for relative urls
This commit is contained in:
parent
294fbd65f3
commit
8ac0f40896
4 changed files with 23 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue