@ztimson/utils 0.23.20 → 0.23.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1249,8 +1249,9 @@ ${opts.message || this.desc}`;
|
|
|
1249
1249
|
request(opts = {}) {
|
|
1250
1250
|
var _a;
|
|
1251
1251
|
if (!this.url && !opts.url) throw new Error("URL needs to be set");
|
|
1252
|
-
let url = ((
|
|
1253
|
-
|
|
1252
|
+
let url = ((_a = opts.url) == null ? void 0 : _a.startsWith("http")) ? opts.url : (this.url || "") + (opts.url || "");
|
|
1253
|
+
url = url.replaceAll(/([^:]\/)\/+/g, "$1");
|
|
1254
|
+
if (opts.fragment) url.includes("#") ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : `${url}#${opts.fragment}`;
|
|
1254
1255
|
if (opts.query) {
|
|
1255
1256
|
const q = Array.isArray(opts.query) ? opts.query : Object.keys(opts.query).map((k) => ({ key: k, value: opts.query[k] }));
|
|
1256
1257
|
url += (url.includes("?") ? "&" : "?") + q.map((q2) => `${q2.key}=${q2.value}`).join("&");
|