More zelous path fixing in the http client
This commit is contained in:
parent
21fc1378b8
commit
f952abc95a
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.23.20",
|
||||
"version": "0.23.21",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -70,8 +70,9 @@ export class Http {
|
||||
|
||||
request<T>(opts: HttpRequestOptions = {}): PromiseProgress<DecodedResponse<T>> {
|
||||
if(!this.url && !opts.url) throw new Error('URL needs to be set');
|
||||
let url = (opts.url?.startsWith('http') ? opts.url : (this.url || '') + (opts.url || '')).replace(/([^:]\/)\/+/g, '$1');
|
||||
if(opts.fragment) url.includes('#') ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : url += '#' + opts.fragment;
|
||||
let url = opts.url?.startsWith('http') ? opts.url : (this.url || '') + (opts.url || '');
|
||||
url = url.replaceAll(/([^:]\/)\/+/g, '$1');
|
||||
if(opts.fragment) url.includes('#') ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : `${url}#${opts.fragment}`;
|
||||
if(opts.query) {
|
||||
const q = Array.isArray(opts.query) ? opts.query :
|
||||
Object.keys(opts.query).map(k => ({key: k, value: (<any>opts.query)[k]}))
|
||||
|
Loading…
x
Reference in New Issue
Block a user