@chriscdn/build-url 1.0.4 → 1.0.6
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/lib/{index.cjs → build-url.cjs} +1 -1
- package/lib/build-url.cjs.map +1 -0
- package/lib/{index.modern.js → build-url.modern.js} +1 -1
- package/lib/build-url.modern.js.map +1 -0
- package/lib/{index.module.js → build-url.module.js} +1 -1
- package/lib/build-url.module.js.map +1 -0
- package/lib/{index.umd.js → build-url.umd.js} +1 -1
- package/lib/build-url.umd.js.map +1 -0
- package/package.json +8 -8
- package/lib/index.cjs.map +0 -1
- package/lib/index.modern.js.map +0 -1
- package/lib/index.module.js.map +0 -1
- package/lib/index.umd.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
module.exports=function(e,a){var r,n=!1;try{r=new URL(e)}catch(a){if(n=!0,"string"==typeof e){var t="undefined"==typeof window?"http://example.com":window.location.origin;r=new URL(t+"/"+e.replace(/^\/|\/$/g,""))}else r="undefined"==typeof window?new URL("http://example.com"):new URL(window.location.href)}var l="string"==typeof e?a:e;if(null!=l&&l.queryParams)for(var o in l.queryParams)if(Object.prototype.hasOwnProperty.call(l.queryParams,o)){var h=l.queryParams[o];null==h?r.searchParams.delete(o):r.searchParams.set(o,h)}return null!=l&&l.path&&(r.pathname=l.path),null===(null==l?void 0:l.path)&&(r.pathname=""),null!=l&&l.hash&&(r.hash=l.hash),!n||null!=l&&l.returnAbsoluteUrl?r.toString():r.pathname+r.search+r.hash};
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=build-url.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-url.cjs","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"eAYwB,SACtBA,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,IAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAOE,MAAQN,EAASU,QAAQ,WAAY,IACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,IAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,IAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,IAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAmB,OAACP,GAExBZ,EAAImB,aAAaC,IAAIR,EAAKK,EAE7B,CAgBL,aAZIP,GAAAA,EAAUW,OACZrB,EAAIsB,SAAWZ,EAASW,MAGH,QAAnBX,MAAAA,OAAAA,EAAAA,EAAUW,QACZrB,EAAIsB,SAAW,UAGbZ,GAAAA,EAAUa,OACZvB,EAAIuB,KAAOb,EAASa,OAGlBtB,SAAoBS,GAAAA,EAAUc,kBAI3BxB,EAAIyB,WAHFzB,EAAIsB,SAAWtB,EAAI0B,OAAS1B,EAAIuB,IAI3C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
function e(e,t){let a,n=!1;try{a=new URL(e)}catch(t){if(n=!0,"string"==typeof e){const t="undefined"==typeof window?"http://example.com":window.location.origin;a=new URL(`${t}/${e.replace(/^\/|\/$/g,"")}`)}else a="undefined"==typeof window?new URL("http://example.com"):new URL(window.location.href)}const r="string"==typeof e?t:e;if(null!=r&&r.queryParams)for(const e in r.queryParams)if(Object.prototype.hasOwnProperty.call(r.queryParams,e)){const t=r.queryParams[e];null==t?a.searchParams.delete(e):a.searchParams.set(e,t)}return null!=r&&r.path&&(a.pathname=r.path),null===(null==r?void 0:r.path)&&(a.pathname=""),null!=r&&r.hash&&(a.hash=r.hash),!n||null!=r&&r.returnAbsoluteUrl?a.toString():a.pathname+a.search+a.hash}export{e as default};
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=build-url.modern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-url.modern.js","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["buildUrl","inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","delete","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"SAYwBA,EACtBC,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,MAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAI,GAAGE,KAAQN,EAASU,QAAQ,WAAY,MACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,MAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,MAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,MAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAaC,OAAOR,GAExBZ,EAAImB,aAAaE,IAAIT,EAAKK,EAE7B,CAgBL,OAZY,MAARP,GAAAA,EAAUY,OACZtB,EAAIuB,SAAWb,EAASY,MAGH,QAAX,MAARZ,OAAQ,EAARA,EAAUY,QACZtB,EAAIuB,SAAW,IAGL,MAARb,GAAAA,EAAUc,OACZxB,EAAIwB,KAAOd,EAASc,OAGlBvB,GAA4B,MAARS,GAAAA,EAAUe,kBAI3BzB,EAAI0B,WAHF1B,EAAIuB,SAAWvB,EAAI2B,OAAS3B,EAAIwB,IAI3C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
function a(a,e){var r,n=!1;try{r=new URL(a)}catch(e){if(n=!0,"string"==typeof a){var t="undefined"==typeof window?"http://example.com":window.location.origin;r=new URL(t+"/"+a.replace(/^\/|\/$/g,""))}else r="undefined"==typeof window?new URL("http://example.com"):new URL(window.location.href)}var l="string"==typeof a?e:a;if(null!=l&&l.queryParams)for(var o in l.queryParams)if(Object.prototype.hasOwnProperty.call(l.queryParams,o)){var h=l.queryParams[o];null==h?r.searchParams.delete(o):r.searchParams.set(o,h)}return null!=l&&l.path&&(r.pathname=l.path),null===(null==l?void 0:l.path)&&(r.pathname=""),null!=l&&l.hash&&(r.hash=l.hash),!n||null!=l&&l.returnAbsoluteUrl?r.toString():r.pathname+r.search+r.hash}export{a as default};
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=build-url.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-url.module.js","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["buildUrl","inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"AAYwB,SAAAA,EACtBC,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,IAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAOE,MAAQN,EAASU,QAAQ,WAAY,IACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,IAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,IAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,IAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAmB,OAACP,GAExBZ,EAAImB,aAAaC,IAAIR,EAAKK,EAE7B,CAgBL,aAZIP,GAAAA,EAAUW,OACZrB,EAAIsB,SAAWZ,EAASW,MAGH,QAAnBX,MAAAA,OAAAA,EAAAA,EAAUW,QACZrB,EAAIsB,SAAW,UAGbZ,GAAAA,EAAUa,OACZvB,EAAIuB,KAAOb,EAASa,OAGlBtB,SAAoBS,GAAAA,EAAUc,kBAI3BxB,EAAIyB,WAHFzB,EAAIsB,SAAWtB,EAAI0B,OAAS1B,EAAIuB,IAI3C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e||self).buildUrl=n()}(this,function(){return function(e,n){var a,t=!1;try{a=new URL(e)}catch(n){if(t=!0,"string"==typeof e){var r="undefined"==typeof window?"http://example.com":window.location.origin;a=new URL(r+"/"+e.replace(/^\/|\/$/g,""))}else a="undefined"==typeof window?new URL("http://example.com"):new URL(window.location.href)}var o="string"==typeof e?n:e;if(null!=o&&o.queryParams)for(var l in o.queryParams)if(Object.prototype.hasOwnProperty.call(o.queryParams,l)){var i=o.queryParams[l];null==i?a.searchParams.delete(l):a.searchParams.set(l,i)}return null!=o&&o.path&&(a.pathname=o.path),null===(null==o?void 0:o.path)&&(a.pathname=""),null!=o&&o.hash&&(a.hash=o.hash),!t||null!=o&&o.returnAbsoluteUrl?a.toString():a.pathname+a.search+a.hash}});
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=build-url.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-url.umd.js","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"kOAYwB,SACtBA,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,IAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAOE,MAAQN,EAASU,QAAQ,WAAY,IACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,IAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,IAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,IAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAmB,OAACP,GAExBZ,EAAImB,aAAaC,IAAIR,EAAKK,EAE7B,CAgBL,aAZIP,GAAAA,EAAUW,OACZrB,EAAIsB,SAAWZ,EAASW,MAGH,QAAnBX,MAAAA,OAAAA,EAAAA,EAAUW,QACZrB,EAAIsB,SAAW,UAGbZ,GAAAA,EAAUa,OACZvB,EAAIuB,KAAOb,EAASa,OAGlBtB,SAAoBS,GAAAA,EAAUc,kBAI3BxB,EAAIyB,WAHFzB,EAAIsB,SAAWtB,EAAI0B,OAAS1B,EAAIuB,IAI3C"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chriscdn/build-url",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "A small utility for building URLs.",
|
|
5
|
-
"repository": "https://github.com/chriscdn/build-url",
|
|
5
|
+
"repository": "https://github.com/chriscdn/build-url.",
|
|
6
6
|
"author": "Christopher Meyer <chris@schwiiz.org>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"source": "
|
|
10
|
-
"main": "./lib/index.cjs",
|
|
11
|
-
"module": "./lib/index.module.js",
|
|
12
|
-
"unpkg": "./lib/index.umd.js",
|
|
9
|
+
"source": "src/index.ts",
|
|
13
10
|
"exports": {
|
|
14
|
-
"require": "./lib/
|
|
15
|
-
"default": "./lib/
|
|
11
|
+
"require": "./lib/build-url.cjs",
|
|
12
|
+
"default": "./lib/build-url.modern.js"
|
|
16
13
|
},
|
|
14
|
+
"main": "./lib/build-url.cjs",
|
|
15
|
+
"module": "./lib/build-url.module.js",
|
|
16
|
+
"unpkg": "./lib/build-url.umd.js",
|
|
17
17
|
"types": "./lib/index.d.ts",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "rm -rf ./lib/ && microbundle",
|
package/lib/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"eAYwB,SACtBA,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,IAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAOE,MAAQN,EAASU,QAAQ,WAAY,IACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,IAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,IAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,IAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAmB,OAACP,GAExBZ,EAAImB,aAAaC,IAAIR,EAAKK,EAE7B,CAgBL,aAZIP,GAAAA,EAAUW,OACZrB,EAAIsB,SAAWZ,EAASW,MAGH,QAAnBX,MAAAA,OAAAA,EAAAA,EAAUW,QACZrB,EAAIsB,SAAW,UAGbZ,GAAAA,EAAUa,OACZvB,EAAIuB,KAAOb,EAASa,OAGlBtB,SAAoBS,GAAAA,EAAUc,kBAI3BxB,EAAIyB,WAHFzB,EAAIsB,SAAWtB,EAAI0B,OAAS1B,EAAIuB,IAI3C"}
|
package/lib/index.modern.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["buildUrl","inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","delete","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"SAYwBA,EACtBC,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,MAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAI,GAAGE,KAAQN,EAASU,QAAQ,WAAY,MACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,MAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,MAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,MAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAaC,OAAOR,GAExBZ,EAAImB,aAAaE,IAAIT,EAAKK,EAE7B,CAgBL,OAZY,MAARP,GAAAA,EAAUY,OACZtB,EAAIuB,SAAWb,EAASY,MAGH,QAAX,MAARZ,OAAQ,EAARA,EAAUY,QACZtB,EAAIuB,SAAW,IAGL,MAARb,GAAAA,EAAUc,OACZxB,EAAIwB,KAAOd,EAASc,OAGlBvB,GAA4B,MAARS,GAAAA,EAAUe,kBAI3BzB,EAAI0B,WAHF1B,EAAIuB,SAAWvB,EAAI2B,OAAS3B,EAAIwB,IAI3C"}
|
package/lib/index.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["buildUrl","inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"AAYwB,SAAAA,EACtBC,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,IAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAOE,MAAQN,EAASU,QAAQ,WAAY,IACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,IAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,IAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,IAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAmB,OAACP,GAExBZ,EAAImB,aAAaC,IAAIR,EAAKK,EAE7B,CAgBL,aAZIP,GAAAA,EAAUW,OACZrB,EAAIsB,SAAWZ,EAASW,MAGH,QAAnBX,MAAAA,OAAAA,EAAAA,EAAUW,QACZrB,EAAIsB,SAAW,UAGbZ,GAAAA,EAAUa,OACZvB,EAAIuB,KAAOb,EAASa,OAGlBtB,SAAoBS,GAAAA,EAAUc,kBAI3BxB,EAAIyB,WAHFzB,EAAIsB,SAAWtB,EAAI0B,OAAS1B,EAAIuB,IAI3C"}
|
package/lib/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["export interface UrlOptions {\n queryParams?: {\n [x: string]: any;\n };\n hash?: string;\n path?: string | null;\n returnAbsoluteUrl?: boolean;\n}\n\nconst isEmpty = (value: any) => value === null || value === undefined;\n// ||(typeof value === \"string\" && value.trim().length === 0);\n\nexport default function buildUrl(\n inputUrl?: string | UrlOptions,\n options?: UrlOptions\n) {\n let url: URL;\n let isValidInputUrl = false;\n\n try {\n url = new URL(inputUrl as string);\n } catch (error) {\n isValidInputUrl = true;\n\n if (typeof inputUrl === \"string\") {\n const host =\n typeof window === \"undefined\"\n ? \"http://example.com\"\n : window.location.origin;\n\n url = new URL(`${host}/${inputUrl.replace(/^\\/|\\/$/g, \"\")}`);\n } else {\n url =\n typeof window === \"undefined\"\n ? new URL(\"http://example.com\")\n : new URL(window.location.href);\n }\n }\n\n const _options = typeof inputUrl === \"string\" ? options : inputUrl;\n\n if (_options?.queryParams) {\n for (const key in _options.queryParams) {\n if (Object.prototype.hasOwnProperty.call(_options.queryParams, key)) {\n const element = _options.queryParams[key];\n\n if (isEmpty(element)) {\n url.searchParams.delete(key);\n } else {\n url.searchParams.set(key, element);\n }\n }\n }\n }\n\n if (_options?.path) {\n url.pathname = _options.path;\n }\n\n if (_options?.path === null) {\n url.pathname = \"\";\n }\n\n if (_options?.hash) {\n url.hash = _options.hash;\n }\n\n if (isValidInputUrl && !_options?.returnAbsoluteUrl) {\n return url.pathname + url.search + url.hash;\n }\n\n return url.toString();\n}\n"],"names":["inputUrl","options","url","isValidInputUrl","URL","error","host","window","location","origin","replace","href","_options","queryParams","key","Object","prototype","hasOwnProperty","call","element","value","searchParams","set","path","pathname","hash","returnAbsoluteUrl","toString","search"],"mappings":"kOAYwB,SACtBA,EACAC,GAEA,IAAIC,EACAC,GAAkB,EAEtB,IACED,EAAM,IAAIE,IAAIJ,EACf,CAAC,MAAOK,GAGP,GAFAF,GAAkB,EAEM,iBAAbH,EAAuB,CAChC,IAAMM,EACc,oBAAXC,OACH,qBACAA,OAAOC,SAASC,OAEtBP,EAAM,IAAIE,IAAOE,MAAQN,EAASU,QAAQ,WAAY,IACvD,MACCR,EACoB,oBAAXK,OACH,IAAIH,IAAI,sBACR,IAAIA,IAAIG,OAAOC,SAASG,KAEjC,CAED,IAAMC,EAA+B,iBAAbZ,EAAwBC,EAAUD,EAE1D,GAAIY,MAAAA,GAAAA,EAAUC,YACZ,IAAK,IAAMC,KAAOF,EAASC,YACzB,GAAIE,OAAOC,UAAUC,eAAeC,KAAKN,EAASC,YAAaC,GAAM,CACnE,IAAMK,EAAUP,EAASC,YAAYC,GAnCbM,MAqCZD,EACVjB,EAAImB,aAAmB,OAACP,GAExBZ,EAAImB,aAAaC,IAAIR,EAAKK,EAE7B,CAgBL,aAZIP,GAAAA,EAAUW,OACZrB,EAAIsB,SAAWZ,EAASW,MAGH,QAAnBX,MAAAA,OAAAA,EAAAA,EAAUW,QACZrB,EAAIsB,SAAW,UAGbZ,GAAAA,EAAUa,OACZvB,EAAIuB,KAAOb,EAASa,OAGlBtB,SAAoBS,GAAAA,EAAUc,kBAI3BxB,EAAIyB,WAHFzB,EAAIsB,SAAWtB,EAAI0B,OAAS1B,EAAIuB,IAI3C"}
|