More efficient regex
Some checks failed
Build / Build NPM Project (push) Successful in 44s
Build / Publish Documentation (push) Failing after 4s
Build / Tag Version (push) Successful in 8s

This commit is contained in:
2025-07-22 14:22:47 -04:00
parent c36af83918
commit b3223661dd
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.26.15",
"version": "0.26.16",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -78,7 +78,7 @@ export class Http {
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 || '');
url = url.replaceAll(/([^:]\/)\/+/g, '$1');
if(opts.fragment) url.includes('#') ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : `${url}#${opts.fragment}`;
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]}))