@rzl-zone/utils-js 3.12.0 → 3.12.1-beta.0
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/{LICENSE.md → LICENSE} +3 -3
- package/README.md +62 -89
- package/dist/.references/index.d.cts +25 -0
- package/dist/.references/index.d.ts +25 -0
- package/dist/assertIsArray-BChqwPiP.cjs +26 -0
- package/dist/assertIsArray-BChqwPiP.cjs.map +1 -0
- package/dist/assertIsArray-BfAbIUfa.js +20 -0
- package/dist/assertIsArray-BfAbIUfa.js.map +1 -0
- package/dist/assertIsBoolean-BlBct0Fc.js +1073 -0
- package/dist/assertIsBoolean-BlBct0Fc.js.map +1 -0
- package/dist/assertIsBoolean-DozdtbNi.cjs +1283 -0
- package/dist/assertIsBoolean-DozdtbNi.cjs.map +1 -0
- package/dist/assertIsString-Bvk7bUL7.cjs +26 -0
- package/dist/assertIsString-Bvk7bUL7.cjs.map +1 -0
- package/dist/assertIsString-DqV9NwbI.js +20 -0
- package/dist/assertIsString-DqV9NwbI.js.map +1 -0
- package/dist/assertions/index.cjs +37 -40
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.d.cts +12 -0
- package/dist/assertions/index.d.ts +10 -824
- package/dist/assertions/index.js +30 -13
- package/dist/assertions/index.js.map +1 -0
- package/dist/conversions/index.cjs +34 -103
- package/dist/conversions/index.d.cts +12 -0
- package/dist/conversions/index.d.ts +10 -1791
- package/dist/conversions/index.js +14 -24
- package/dist/conversions-CBs8-REq.cjs +448 -0
- package/dist/conversions-CBs8-REq.cjs.map +1 -0
- package/dist/conversions-EMJa3g-D.js +382 -0
- package/dist/conversions-EMJa3g-D.js.map +1 -0
- package/dist/events/index.cjs +55 -31
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.d.cts +174 -0
- package/dist/events/index.d.ts +31 -35
- package/dist/events/index.js +50 -12
- package/dist/events/index.js.map +1 -0
- package/dist/formatEnvPort-DpIXzPAZ.js +159 -0
- package/dist/formatEnvPort-DpIXzPAZ.js.map +1 -0
- package/dist/formatEnvPort-hHNvOim-.cjs +171 -0
- package/dist/formatEnvPort-hHNvOim-.cjs.map +1 -0
- package/dist/formatters/index.cjs +21 -61
- package/dist/formatters/index.d.cts +12 -0
- package/dist/formatters/index.d.ts +10 -2152
- package/dist/formatters/index.js +10 -18
- package/dist/formatters-QcZO_Cpx.js +367 -0
- package/dist/formatters-QcZO_Cpx.js.map +1 -0
- package/dist/formatters-lAYgA11L.cjs +427 -0
- package/dist/formatters-lAYgA11L.cjs.map +1 -0
- package/dist/generators/index.cjs +161 -41
- package/dist/generators/index.cjs.map +1 -0
- package/dist/generators/index.d.cts +12 -0
- package/dist/generators/index.d.ts +10 -338
- package/dist/generators/index.js +154 -14
- package/dist/generators/index.js.map +1 -0
- package/dist/index-26W7ItWx.d.ts +760 -0
- package/dist/index-BPPQjAfs.d.cts +2359 -0
- package/dist/index-BXjlgBLz.d.cts +2139 -0
- package/dist/index-B_Wwo91H.d.ts +2359 -0
- package/dist/index-CpufydcI.d.cts +704 -0
- package/dist/index-Czc4O526.d.ts +333 -0
- package/dist/index-DPs1_p5G.d.cts +760 -0
- package/dist/index-DRpOyBSC.d.ts +1703 -0
- package/dist/index-DWWvtHUn.d.cts +822 -0
- package/dist/index-DnM0LD0n.d.cts +333 -0
- package/dist/index-GUZ9fK6T.d.ts +2139 -0
- package/dist/index-I4fAzwXV.d.ts +704 -0
- package/dist/index-JDrOl_19.d.ts +822 -0
- package/dist/index-b66P49Qe.d.cts +1703 -0
- package/dist/isBigInt-B1cijjqm.cjs +20 -0
- package/dist/isBigInt-B1cijjqm.cjs.map +1 -0
- package/dist/isBigInt-C0bN0Rhu.js +14 -0
- package/dist/isBigInt-C0bN0Rhu.js.map +1 -0
- package/dist/isEmptyObject-DI42NEo0.cjs +37 -0
- package/dist/isEmptyObject-DI42NEo0.cjs.map +1 -0
- package/dist/isEmptyObject-DeLVIJpl.js +25 -0
- package/dist/isEmptyObject-DeLVIJpl.js.map +1 -0
- package/dist/isEmptyString-BTUWYTbw.js +15 -0
- package/dist/isEmptyString-BTUWYTbw.js.map +1 -0
- package/dist/isEmptyString-CCK3bP74.cjs +21 -0
- package/dist/isEmptyString-CCK3bP74.cjs.map +1 -0
- package/dist/isEmptyValue-DMSMFTU8.cjs +30 -0
- package/dist/isEmptyValue-DMSMFTU8.cjs.map +1 -0
- package/dist/isEmptyValue-fjnfQnt5.js +24 -0
- package/dist/isEmptyValue-fjnfQnt5.js.map +1 -0
- package/dist/isEqual-B1fRgEuU.cjs +111 -0
- package/dist/isEqual-B1fRgEuU.cjs.map +1 -0
- package/dist/isEqual-DhyP8fB_.js +87 -0
- package/dist/isEqual-DhyP8fB_.js.map +1 -0
- package/dist/isFinite-BYMOo0os.js +15 -0
- package/dist/isFinite-BYMOo0os.js.map +1 -0
- package/dist/isFinite-sFkps2TY.cjs +21 -0
- package/dist/isFinite-sFkps2TY.cjs.map +1 -0
- package/dist/isInteger-DS9V7l_f.js +14 -0
- package/dist/isInteger-DS9V7l_f.js.map +1 -0
- package/dist/isInteger-FTCthMre.cjs +20 -0
- package/dist/isInteger-FTCthMre.cjs.map +1 -0
- package/dist/isPlainObject-DcFGh3_5.d.ts +530 -0
- package/dist/isPlainObject-doTI11Ib.d.cts +530 -0
- package/dist/isServer-D1TXfOs3.js +14 -0
- package/dist/isServer-D1TXfOs3.js.map +1 -0
- package/dist/isServer-q-QLFCqE.cjs +20 -0
- package/dist/isServer-q-QLFCqE.cjs.map +1 -0
- package/dist/isTypedArray-47R0wdrc.js +31 -0
- package/dist/isTypedArray-47R0wdrc.js.map +1 -0
- package/dist/isTypedArray-DiCoqffZ.cjs +43 -0
- package/dist/isTypedArray-DiCoqffZ.cjs.map +1 -0
- package/dist/isURL-CQiowFq2.js +14 -0
- package/dist/isURL-CQiowFq2.js.map +1 -0
- package/dist/isURL-WZypXsax.cjs +20 -0
- package/dist/isURL-WZypXsax.cjs.map +1 -0
- package/dist/isValidDomain-BSXshgkC.cjs +1788 -0
- package/dist/isValidDomain-BSXshgkC.cjs.map +1 -0
- package/dist/isValidDomain-DwA2EN79.js +1782 -0
- package/dist/isValidDomain-DwA2EN79.js.map +1 -0
- package/dist/next/index.cjs +119 -214
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +226 -0
- package/dist/next/index.d.ts +26 -31
- package/dist/next/index.js +117 -212
- package/dist/next/index.js.map +1 -0
- package/dist/next/server/index.cjs +25 -40
- package/dist/next/server/index.cjs.map +1 -0
- package/dist/next/server/index.d.cts +39 -0
- package/dist/next/server/index.d.ts +9 -10
- package/dist/next/server/index.js +23 -38
- package/dist/next/server/index.js.map +1 -0
- package/dist/noop-B2mTBhW-.cjs +18 -0
- package/dist/noop-B2mTBhW-.cjs.map +1 -0
- package/dist/noop-BzktGBVz.js +12 -0
- package/dist/noop-BzktGBVz.js.map +1 -0
- package/dist/normalizeSpaces-DQHR3Tlr.cjs +29 -0
- package/dist/normalizeSpaces-DQHR3Tlr.cjs.map +1 -0
- package/dist/normalizeSpaces-WS_iERJk.js +23 -0
- package/dist/normalizeSpaces-WS_iERJk.js.map +1 -0
- package/dist/normalizeString-2WLth_Gj.js +15 -0
- package/dist/normalizeString-2WLth_Gj.js.map +1 -0
- package/dist/normalizeString-D8euBcRD.cjs +21 -0
- package/dist/normalizeString-D8euBcRD.cjs.map +1 -0
- package/dist/operations/index.cjs +65 -32
- package/dist/operations/index.cjs.map +1 -0
- package/dist/operations/index.d.cts +139 -0
- package/dist/operations/index.d.ts +10 -15
- package/dist/operations/index.js +61 -17
- package/dist/operations/index.js.map +1 -0
- package/dist/parsers/index.cjs +12 -19
- package/dist/parsers/index.d.cts +239 -0
- package/dist/parsers/index.d.ts +71 -72
- package/dist/parsers/index.js +10 -12
- package/dist/parsers-DXtpsDyj.cjs +649 -0
- package/dist/parsers-DXtpsDyj.cjs.map +1 -0
- package/dist/parsers-Dpuq-V4u.js +643 -0
- package/dist/parsers-Dpuq-V4u.js.map +1 -0
- package/dist/parsing-B43x1sxn.js +50 -0
- package/dist/parsing-B43x1sxn.js.map +1 -0
- package/dist/parsing-lRoxn1Nz.cjs +56 -0
- package/dist/parsing-lRoxn1Nz.cjs.map +1 -0
- package/dist/predicates/index.cjs +91 -296
- package/dist/predicates/index.d.cts +13 -0
- package/dist/predicates/index.d.ts +12 -2482
- package/dist/predicates/index.js +23 -25
- package/dist/predicates-DiaYA7Ps.cjs +413 -0
- package/dist/predicates-DiaYA7Ps.cjs.map +1 -0
- package/dist/predicates-gNepszvo.js +257 -0
- package/dist/predicates-gNepszvo.js.map +1 -0
- package/dist/promises/index.cjs +76 -24
- package/dist/promises/index.cjs.map +1 -0
- package/dist/promises/index.d.cts +123 -0
- package/dist/promises/index.d.ts +28 -31
- package/dist/promises/index.js +73 -13
- package/dist/promises/index.js.map +1 -0
- package/dist/punyCode-CTWXVVFo.cjs +185 -0
- package/dist/punyCode-CTWXVVFo.cjs.map +1 -0
- package/dist/punyCode-hmiFzLWT.js +179 -0
- package/dist/punyCode-hmiFzLWT.js.map +1 -0
- package/dist/removeSpaces-BE8lfh-4.js +19 -0
- package/dist/removeSpaces-BE8lfh-4.js.map +1 -0
- package/dist/removeSpaces-DRRxNWlb.cjs +25 -0
- package/dist/removeSpaces-DRRxNWlb.cjs.map +1 -0
- package/dist/safeJsonParse-BBnQElk8.cjs +208 -0
- package/dist/safeJsonParse-BBnQElk8.cjs.map +1 -0
- package/dist/safeJsonParse-CXruaP0p.js +184 -0
- package/dist/safeJsonParse-CXruaP0p.js.map +1 -0
- package/dist/safeStableStringify-BNh3D0K0.js +88 -0
- package/dist/safeStableStringify-BNh3D0K0.js.map +1 -0
- package/dist/safeStableStringify-Cc62pfRp.cjs +106 -0
- package/dist/safeStableStringify-Cc62pfRp.cjs.map +1 -0
- package/dist/strings/index.cjs +76 -81
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +12 -0
- package/dist/strings/index.d.ts +10 -775
- package/dist/strings/index.js +59 -14
- package/dist/strings/index.js.map +1 -0
- package/dist/tailwind/index.cjs +19 -47
- package/dist/tailwind/index.d.cts +12 -0
- package/dist/tailwind/index.d.ts +11 -712
- package/dist/tailwind/index.js +10 -12
- package/dist/tailwind-DJ4cmLUw.cjs +247 -0
- package/dist/tailwind-DJ4cmLUw.cjs.map +1 -0
- package/dist/tailwind-IJvOdkZp.js +199 -0
- package/dist/tailwind-IJvOdkZp.js.map +1 -0
- package/dist/toStringArrayUnRecursive-CFs0jTEg.js +39 -0
- package/dist/toStringArrayUnRecursive-CFs0jTEg.js.map +1 -0
- package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs +51 -0
- package/dist/toStringArrayUnRecursive-xUaU8Ot9.cjs.map +1 -0
- package/dist/urls/index.cjs +129 -57
- package/dist/urls/index.cjs.map +1 -0
- package/dist/urls/index.d.cts +740 -0
- package/dist/urls/index.d.ts +218 -224
- package/dist/urls/index.js +121 -26
- package/dist/urls/index.js.map +1 -0
- package/package.json +203 -194
- package/dist/chunk-2AFQ33D3.cjs +0 -64
- package/dist/chunk-2CYDJVGM.js +0 -246
- package/dist/chunk-2MW4JDQ2.cjs +0 -598
- package/dist/chunk-2VTDXC3N.cjs +0 -1825
- package/dist/chunk-44XX2P34.js +0 -209
- package/dist/chunk-4YLBKLGS.cjs +0 -18
- package/dist/chunk-566CXQW7.cjs +0 -560
- package/dist/chunk-57EPKYID.cjs +0 -397
- package/dist/chunk-5MGEC3YG.js +0 -63
- package/dist/chunk-6EF52423.cjs +0 -249
- package/dist/chunk-6SCOKU3S.js +0 -109
- package/dist/chunk-6VUXD3CF.js +0 -119
- package/dist/chunk-7B76BSNK.cjs +0 -118
- package/dist/chunk-7Y6I2DSU.cjs +0 -101
- package/dist/chunk-A7S7E2EE.cjs +0 -308
- package/dist/chunk-AJZ6PMMZ.js +0 -16
- package/dist/chunk-AXGBL2IO.cjs +0 -251
- package/dist/chunk-B4TC6FBV.cjs +0 -678
- package/dist/chunk-BAV5T2E3.cjs +0 -15
- package/dist/chunk-BKIJBNIE.js +0 -21
- package/dist/chunk-BNIMTFK5.js +0 -59
- package/dist/chunk-BXW7YXB7.js +0 -1823
- package/dist/chunk-CFYZC4S6.js +0 -53
- package/dist/chunk-CSG4SCL3.js +0 -1587
- package/dist/chunk-CWQW7AKK.js +0 -676
- package/dist/chunk-DVMHRLKP.cjs +0 -16
- package/dist/chunk-EN7LVZBZ.js +0 -548
- package/dist/chunk-EV4Y7HCY.cjs +0 -26
- package/dist/chunk-F66VDYIZ.cjs +0 -18
- package/dist/chunk-FLJX37EL.cjs +0 -30
- package/dist/chunk-GKC3UDMC.cjs +0 -1623
- package/dist/chunk-H65I3GRZ.cjs +0 -106
- package/dist/chunk-HHYWB7VZ.js +0 -24
- package/dist/chunk-HNGGISFL.cjs +0 -65
- package/dist/chunk-HNSQAVSZ.cjs +0 -35
- package/dist/chunk-HSP6IWZK.js +0 -17
- package/dist/chunk-IDZS7J6T.js +0 -242
- package/dist/chunk-JS6R55VL.js +0 -302
- package/dist/chunk-JZVT5FK7.js +0 -232
- package/dist/chunk-KHO2SBNA.cjs +0 -16
- package/dist/chunk-KIDJCMNJ.js +0 -33
- package/dist/chunk-KOLEURVT.cjs +0 -38
- package/dist/chunk-L4V53MQK.cjs +0 -269
- package/dist/chunk-L5RDAVVH.js +0 -14
- package/dist/chunk-NODTV4F3.js +0 -16
- package/dist/chunk-NYK5K3V2.cjs +0 -211
- package/dist/chunk-ODUO3RTL.cjs +0 -113
- package/dist/chunk-ONZFBJVW.js +0 -14
- package/dist/chunk-PFXCTE37.js +0 -28
- package/dist/chunk-PPST7QAQ.js +0 -587
- package/dist/chunk-Q5IMYDFL.cjs +0 -33
- package/dist/chunk-QFFBIOJ4.js +0 -31
- package/dist/chunk-QNKGP5DY.js +0 -14
- package/dist/chunk-RRQHMOPE.cjs +0 -19
- package/dist/chunk-RU5OSRBU.js +0 -95
- package/dist/chunk-SDMPEJ4F.js +0 -35
- package/dist/chunk-SYNL5IKP.js +0 -115
- package/dist/chunk-TCDOWZQE.js +0 -16
- package/dist/chunk-TQPGXGKB.cjs +0 -123
- package/dist/chunk-TULOI4GL.js +0 -370
- package/dist/chunk-UBHCP4N5.cjs +0 -36
- package/dist/chunk-UCHF3M34.cjs +0 -56
- package/dist/chunk-UDA26MCU.cjs +0 -16
- package/dist/chunk-V3C4FYZL.cjs +0 -18
- package/dist/chunk-VAAHZFBF.js +0 -32
- package/dist/chunk-VJDDGRIK.cjs +0 -16
- package/dist/chunk-WVSPXFTY.js +0 -14
- package/dist/chunk-WYP76WXB.js +0 -101
- package/dist/chunk-YDE4ZBB7.cjs +0 -237
- package/dist/chunk-YKQEOO7C.cjs +0 -23
- package/dist/chunk-YSZC56SZ.js +0 -264
- package/dist/chunk-YWHHVDT4.js +0 -13
- package/dist/index.d.ts +0 -24
- package/dist/isPlainObject-DTJVV2Kf.d.ts +0 -536
- package/dist/rzl-utils.global.js +0 -10
package/dist/events/index.js
CHANGED
|
@@ -1,13 +1,51 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.12.1-beta.0`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
import { A as isPlainObject, b as hasOwnProp, w as isNumber, y as isNonEmptyString } from "../assertIsBoolean-BlBct0Fc.js";
|
|
11
|
+
import { t as assertIsString } from "../assertIsString-DqV9NwbI.js";
|
|
12
|
+
import { t as isServer } from "../isServer-D1TXfOs3.js";
|
|
13
|
+
const disableUserInteraction = (className = "on_processing") => {
|
|
14
|
+
if (isServer()) return;
|
|
15
|
+
assertIsString(className, { message({ validType, currentType }) {
|
|
16
|
+
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
17
|
+
} });
|
|
18
|
+
const { documentElement } = document;
|
|
19
|
+
if (documentElement && !documentElement.classList.contains(className)) documentElement.classList.add(className);
|
|
20
|
+
};
|
|
21
|
+
const enableUserInteraction = (className = "on_processing") => {
|
|
22
|
+
if (isServer()) return;
|
|
23
|
+
assertIsString(className, { message({ validType, currentType }) {
|
|
24
|
+
return `First parameter \`className\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
25
|
+
} });
|
|
26
|
+
const { documentElement } = document;
|
|
27
|
+
if (documentElement && documentElement.classList.contains(className)) documentElement.classList.remove(className);
|
|
28
|
+
};
|
|
29
|
+
const removeElementFocus = () => {
|
|
30
|
+
if (isServer()) return;
|
|
31
|
+
const activeElement = document.activeElement;
|
|
32
|
+
if (activeElement instanceof HTMLElement) activeElement.blur();
|
|
33
|
+
};
|
|
34
|
+
const scrollToTop = (options) => {
|
|
35
|
+
if (isServer()) return;
|
|
36
|
+
if (!isPlainObject(options)) options = {};
|
|
37
|
+
const behavior = hasOwnProp(options, "behavior") && isNonEmptyString(options.behavior) && [
|
|
38
|
+
"auto",
|
|
39
|
+
"instant",
|
|
40
|
+
"smooth"
|
|
41
|
+
].includes(options.behavior) ? options.behavior : "smooth";
|
|
42
|
+
let timeout = hasOwnProp(options, "timeout") && isNumber(options.timeout) && options.timeout >= 1 ? options.timeout : 1;
|
|
43
|
+
timeout = timeout > 2147483647 ? 2147483647 : timeout;
|
|
44
|
+
setTimeout(() => window.scrollTo({
|
|
45
|
+
top: 0,
|
|
46
|
+
left: 0,
|
|
47
|
+
behavior
|
|
48
|
+
}), timeout);
|
|
49
|
+
};
|
|
50
|
+
export { disableUserInteraction, enableUserInteraction, removeElementFocus, scrollToTop };
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/events/actions/disableUserInteraction.ts","../../src/events/actions/enableUserInteraction.ts","../../src/events/actions/removeElementFocus.ts","../../src/events/actions/scrollToTop.ts"],"sourcesContent":["import { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `disableUserInteraction`.***\n * ----------------------------------------------------------\n * **Disables user interaction by adding a CSS class to the `<html>` element.**\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely adds the specified CSS class to `<html>`.\n * - Prevents multiple additions of the same class.\n * - Useful to indicate that a process is ongoing\n * (e.g., loading or processing state).\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will add it and disable interactions accordingly.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n * @defaultValue `\"on_processing\"`\n * @param {string} [className=\"on_processing\"] - The CSS class to add, defaults to `\"on_processing\"`.\n * @returns {void} Does not return anything (void).\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n * @example\n * * ***Example in your code:***\n * ```ts\n * disableUserInteraction(); // ➔ Adds \"on_processing\" class\n * disableUserInteraction(\"loading\"); // ➔ Adds \"loading\" class\n * // ❌ Invalid value:\n * disableUserInteraction(123); // ➔ Throws TypeError\n * ```\n * * ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const disableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && !documentElement.classList.contains(className)) {\n documentElement.classList.add(className);\n }\n};\n","import { isServer } from \"@/predicates/is/isServer\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `enableUserInteraction`.***\n * ----------------------------------------------------------\n * **Enables user interaction by removing a CSS class from the `<html>` element.**\n * - **Key points**:\n * - Works **only in browser environments**.\n * - Safely removes the specified CSS class from `<html>`.\n * - Does nothing if the class is not present.\n * - Useful to re-enable user interactions after a process\n * (e.g., loading or processing) completes.\n * - **Using custom CSS classes:**\n * - You can pass any class name that exists in your CSS.\n * - Example: if you have `.loading` in your styles, passing `\"loading\"`\n * will remove it and re-enable interactions.\n * - **Validation:**\n * - Throws `TypeError` if the `className` parameter is not a string.\n * @defaultValue `\"on_processing\"`\n * @param {string} [className=\"on_processing\"] - The CSS class to remove, defaults to `\"on_processing\"`.\n * @returns {void} Does not return anything (void).\n * @throws **{@link TypeError | `TypeError`}** if `className` is not a string.\n * @example\n * * ***Example in your code:***\n * ```ts\n * enableUserInteraction(); // ➔ Removes \"on_processing\" class\n * enableUserInteraction(\"loading\"); // ➔ Removes \"loading\" class\n * // ❌ Invalid value:\n * enableUserInteraction(123); // ➔ Throws TypeError\n * ```\n * * ***Example in your css file (with defaultValue `className` props [on_processing]):***\n * ```css\n * .on_processing {\n * cursor: wait;\n * touch-action: none;\n * user-select: none;\n * }\n *\n * .on_processing > * {\n * pointer-events: none;\n * touch-action: none;\n * user-select: none;\n * }\n * ```\n */\nexport const enableUserInteraction = (\n className: string = \"on_processing\"\n): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n assertIsString(className, {\n message({ validType, currentType }) {\n return `First parameter \\`className\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const { documentElement } = document;\n\n if (documentElement && documentElement.classList.contains(className)) {\n documentElement.classList.remove(className);\n }\n};\n","import { isServer } from \"@/predicates/is/isServer\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `removeElementFocus`.***\n * ----------------------------------------------------------\n * **Removes focus from the currently active element in the document.**\n * - **Features**:\n * - This function works **only in browser environments** ***(safely no-ops in server environments)***.\n * - If an element is focused, it will lose focus by calling `HTMLElement.blur()`.\n * - If no element is focused or the active element is not an `HTMLElement`, nothing happens.\n * @returns {void} Does not return anything (void).\n * @example\n * removeElementFocus(); // ➔ Removes focus from the currently active element\n */\nexport const removeElementFocus = (): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n const activeElement = document.activeElement;\n\n if (activeElement instanceof HTMLElement) {\n activeElement.blur();\n } else {\n // not-support, currently we nothing to do...\n // console.warn(\"removeElementFocus: No active element to blur or unsupported element type.\");\n }\n};\n","import { isNumber } from \"@/predicates/is/isNumber\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isServer } from \"@/predicates/is/isServer\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/** @private ***Types options for {@link scrollToTop | `scrollToTop`}.*** */\ntype ScrollToTopOptions = {\n /** ----------------------------------------------------------\n * * ***Scroll animation type.***\n * ----------------------------------------------------------\n * - ***Behavior:***\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n *\n * @default \"smooth\"\n */\n behavior?: ScrollBehavior | undefined;\n /** ----------------------------------------------------------\n * * ***Delay before scrolling (in milliseconds).***\n * ----------------------------------------------------------\n * - ***Behavior:***\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid-type`, or `less-than` `1`.\n *\n * @default 1\n */\n timeout?: number | undefined;\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `scrollToTop`.***\n * ----------------------------------------------------------\n * **Scrolls the page to the top with optional smooth animation and delay.**\n * - **Features**:\n * - This function works **only in browser environments** (no effect on server-side).\n * - It leverages the native `window.scrollTo()` API with support for smooth scrolling\n * and an optional timeout delay before executing the scroll.\n * - Each option has strict valid values.\n * - If an invalid value is provided, the function **automatically falls back to its default**.\n * @param {ScrollToTopOptions} [options] - Optional settings for scroll behavior.\n * @param {ScrollToTopOptions[\"behavior\"]} [options.behavior=\"smooth\"] - Scroll animation type.\n * - Valid values: `\"auto\"`, `\"instant\"`, `\"smooth\"`.\n * - Default force to `\"smooth\"` if missing or invalid.\n * @param {ScrollToTopOptions[\"timeout\"]} [options.timeout=1] - Delay before scrolling (in milliseconds).\n * - Default value is `1`.\n * - Valid values: any number `≥` `1`.\n * - Non-integer number are truncated to an integer.\n * - Force to `2147483647` if number is larger than `2147483647`.\n * - Default force to `1` if `missing`, `NaN`, `invalid`, or `less-than` `1`.\n * @returns {void} Does not return anything, only scrolling to top (void).\n * @example\n * // ✅ Valid options value:\n * scrollToTop();\n * // ➔ Scroll smoothly to the top after 1ms delay\n * scrollToTop({ behavior: \"instant\" });\n * // ➔ Jump instantly to the top\n * scrollToTop({ timeout: 500 });\n * // ➔ Scroll smoothly to the top after 500ms\n *\n * // ❌ Invalid options value:\n * scrollToTop({ behavior: \"fly\", timeout: -100 });\n * // ➔ Fallback: behavior=\"smooth\", timeout=1\n * scrollToTop({ behavior: \"fly\", timeout: 123.55 });\n * // ➔ Fallback: behavior=\"smooth\", timeout=123\n */\nexport const scrollToTop = (options?: ScrollToTopOptions): void => {\n // Ensure function runs only in the browser\n if (isServer()) return;\n\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const behavior: ScrollBehavior =\n hasOwnProp(options, \"behavior\") &&\n isNonEmptyString(options.behavior) &&\n [\"auto\", \"instant\", \"smooth\"].includes(options.behavior)\n ? options.behavior\n : \"smooth\";\n let timeout =\n hasOwnProp(options, \"timeout\") &&\n isNumber(options.timeout) &&\n options.timeout >= 1\n ? options.timeout\n : 1;\n\n timeout = timeout > 2147483647 ? 2147483647 : timeout;\n\n setTimeout(() => window.scrollTo({ top: 0, left: 0, behavior }), timeout);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,0BACX,YAAoB,oBACX;CAET,IAAI,UAAU,EAAE;CAEhB,eAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,mDAAmD,UAAU,sBAAsB,YAAY;IAEzG,CAAC;CAEF,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,CAAC,gBAAgB,UAAU,SAAS,UAAU,EACnE,gBAAgB,UAAU,IAAI,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACf5C,MAAa,yBACX,YAAoB,oBACX;CAET,IAAI,UAAU,EAAE;CAEhB,eAAe,WAAW,EACxB,QAAQ,EAAE,WAAW,eAAe;EAClC,OAAO,mDAAmD,UAAU,sBAAsB,YAAY;IAEzG,CAAC;CAEF,MAAM,EAAE,oBAAoB;CAE5B,IAAI,mBAAmB,gBAAgB,UAAU,SAAS,UAAU,EAClE,gBAAgB,UAAU,OAAO,UAAU;;;;;;;;;;;;;;;;;AC/C/C,MAAa,2BAAiC;CAE5C,IAAI,UAAU,EAAE;CAEhB,MAAM,gBAAgB,SAAS;CAE/B,IAAI,yBAAyB,aAC3B,cAAc,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgDxB,MAAa,eAAe,YAAuC;CAEjE,IAAI,UAAU,EAAE;CAGhB,IAAI,CAAC,cAAc,QAAQ,EACzB,UAAU,EAAE;CAGd,MAAM,WACJ,WAAW,SAAS,WAAW,IAC/B,iBAAiB,QAAQ,SAAS,IAClC;EAAC;EAAQ;EAAW;EAAS,CAAC,SAAS,QAAQ,SAAS,GACpD,QAAQ,WACR;CACN,IAAI,UACF,WAAW,SAAS,UAAU,IAC9B,SAAS,QAAQ,QAAQ,IACzB,QAAQ,WAAW,IACf,QAAQ,UACR;CAEN,UAAU,UAAU,aAAa,aAAa;CAE9C,iBAAiB,OAAO,SAAS;EAAE,KAAK;EAAG,MAAM;EAAG;EAAU,CAAC,EAAE,QAAQ"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.12.1-beta.0`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
import { E as isNull, F as isBoolean, M as isArray, N as isNil, P as isFunction, S as isUndefined, T as assertIsPlainObject, b as hasOwnProp, f as isSet, k as isString, r as getPreciseType, t as assertIsBoolean, v as isError, y as isNonEmptyString } from "./assertIsBoolean-BlBct0Fc.js";
|
|
11
|
+
import { t as safeStableStringify } from "./safeStableStringify-BNh3D0K0.js";
|
|
12
|
+
import { t as isEmptyString } from "./isEmptyString-BTUWYTbw.js";
|
|
13
|
+
import { t as isValidDomain } from "./isValidDomain-DwA2EN79.js";
|
|
14
|
+
import { t as removeSpaces } from "./removeSpaces-BE8lfh-4.js";
|
|
15
|
+
var NormalizePathnameError = class NormalizePathnameError extends Error {
|
|
16
|
+
originalError;
|
|
17
|
+
constructor(message, originalError) {
|
|
18
|
+
super(message, isFunction(Error) ? { cause: originalError } : void 0);
|
|
19
|
+
this.name = "NormalizePathnameError";
|
|
20
|
+
this.originalError = originalError;
|
|
21
|
+
if (isFunction(Error.captureStackTrace)) Error.captureStackTrace(this, NormalizePathnameError);
|
|
22
|
+
else this.stack = new Error(message).stack;
|
|
23
|
+
}
|
|
24
|
+
toJSON() {
|
|
25
|
+
return {
|
|
26
|
+
name: this.name,
|
|
27
|
+
message: this.message,
|
|
28
|
+
stack: this.stack,
|
|
29
|
+
originalError: {
|
|
30
|
+
name: this.originalError.name,
|
|
31
|
+
message: this.originalError.message,
|
|
32
|
+
stack: this.originalError.stack
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function normalizePathname(pathname, options = {
|
|
38
|
+
defaultPath: "/",
|
|
39
|
+
keepNullable: false
|
|
40
|
+
}) {
|
|
41
|
+
assertIsPlainObject(options, { message({ currentType, validType }) {
|
|
42
|
+
return `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
43
|
+
} });
|
|
44
|
+
const { defaultPath = "/", keepNullable = false, keepTrailingSlash = false, localhostDomain = false, ignoreDomainExtensions = void 0 } = options;
|
|
45
|
+
if (!isNonEmptyString(defaultPath)) throw new TypeError(`Parameter \`defaultPath\` property of the \`options\` (second parameter) must be of type \`string\` and not empty-string, but received: \`${getPreciseType(defaultPath)}\`, with value: \`${safeStableStringify(defaultPath, { keepUndefined: true })}\`.`);
|
|
46
|
+
assertIsBoolean(keepNullable, { message({ currentType, validType }) {
|
|
47
|
+
return `Parameter \`keepNullable\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
48
|
+
} });
|
|
49
|
+
assertIsBoolean(keepTrailingSlash, { message({ currentType, validType }) {
|
|
50
|
+
return `Parameter \`keepTrailingSlash\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
51
|
+
} });
|
|
52
|
+
assertIsBoolean(localhostDomain, { message({ currentType, validType }) {
|
|
53
|
+
return `Parameter \`localhostDomain\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
54
|
+
} });
|
|
55
|
+
let ignoreDomainExtsSet;
|
|
56
|
+
if (!isUndefined(ignoreDomainExtensions)) {
|
|
57
|
+
if (!isSet(ignoreDomainExtensions) && !isArray(ignoreDomainExtensions)) throw new TypeError(`Parameter \`ignoreDomainExtensions\` must be of type a \`Set<string>\` or \`string[]\`, but received: \`${getPreciseType(ignoreDomainExtensions)}\`.`);
|
|
58
|
+
ignoreDomainExtsSet = isSet(ignoreDomainExtensions) ? ignoreDomainExtensions : new Set(ignoreDomainExtensions);
|
|
59
|
+
let idx = 0;
|
|
60
|
+
for (const ext of ignoreDomainExtsSet) {
|
|
61
|
+
if (!isNonEmptyString(ext)) throw new TypeError(`Parameter \`ignoreDomainExtensions[${idx}]\` must be a \`string\` and \`non-empty string\`, but received: \`${safeStableStringify(ext, { keepUndefined: true })}\`.`);
|
|
62
|
+
if (!ext.startsWith(".")) throw new TypeError(`Parameter \`ignoreDomainExtensions[${idx}]\` must start with a dot (.), but received: ${safeStableStringify(ext, { keepUndefined: true })}`);
|
|
63
|
+
idx++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
if (keepNullable && (isNil(pathname) || !isString(pathname))) {
|
|
68
|
+
if (isNull(pathname)) return null;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
let currentPathName = isNonEmptyString(pathname) ? pathname : defaultPath;
|
|
72
|
+
currentPathName = removeSpaces(currentPathName, { trimOnly: true }).replace(/\s+/g, "");
|
|
73
|
+
currentPathName = stripLeadingDomain(currentPathName, {
|
|
74
|
+
keepTrailingSlash,
|
|
75
|
+
localhostDomain,
|
|
76
|
+
ignoreDomainExtensions: ignoreDomainExtsSet
|
|
77
|
+
});
|
|
78
|
+
let _pathName = currentPathName;
|
|
79
|
+
let search = "";
|
|
80
|
+
let hash = "";
|
|
81
|
+
const searchIndex = currentPathName.indexOf("?");
|
|
82
|
+
const hashIndex = currentPathName.indexOf("#");
|
|
83
|
+
if (searchIndex !== -1) search = currentPathName.slice(searchIndex, hashIndex !== -1 ? hashIndex : void 0);
|
|
84
|
+
if (hashIndex !== -1) hash = currentPathName.slice(hashIndex);
|
|
85
|
+
const endIndex = Math.min(searchIndex !== -1 ? searchIndex : currentPathName.length, hashIndex !== -1 ? hashIndex : currentPathName.length);
|
|
86
|
+
_pathName = currentPathName.slice(0, endIndex);
|
|
87
|
+
_pathName = "/" + _pathName.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
|
|
88
|
+
if (!keepTrailingSlash && _pathName !== "/") _pathName = _pathName.replace(/\/+$/, "");
|
|
89
|
+
_pathName = decodeUnicodeSequences(_pathName);
|
|
90
|
+
search = decodeUnicodeSequences(search);
|
|
91
|
+
hash = decodeUnicodeSequences(hash);
|
|
92
|
+
return _pathName + search + hash;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throwError(error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const decodeUnicodeSequences = (str) => {
|
|
98
|
+
return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {
|
|
99
|
+
try {
|
|
100
|
+
const decoded = decodeURIComponent(match);
|
|
101
|
+
if (/^[\u0000-\u007F]+$/.test(decoded)) return match;
|
|
102
|
+
return decoded;
|
|
103
|
+
} catch {
|
|
104
|
+
return match;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
const stripLeadingDomain = (path, options) => {
|
|
109
|
+
let currentPath = path;
|
|
110
|
+
const { ignoreDomainExtensions, localhostDomain } = options;
|
|
111
|
+
if (/^https?:\/\//i.test(currentPath)) try {
|
|
112
|
+
const url = new URL(currentPath);
|
|
113
|
+
currentPath = url.pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/") + url.search + url.hash;
|
|
114
|
+
return ensureLeadingSlash(currentPath);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throwError(error);
|
|
117
|
+
}
|
|
118
|
+
if (currentPath.startsWith("/")) currentPath = currentPath.replace(/\/{2,}/g, "/").slice(1);
|
|
119
|
+
const segments = currentPath.split("/");
|
|
120
|
+
const firstPart = segments[0];
|
|
121
|
+
const domainPart = firstPart.split(":")[0];
|
|
122
|
+
const isDomain = isValidDomain(domainPart, {
|
|
123
|
+
subdomain: true,
|
|
124
|
+
allowUnicode: true,
|
|
125
|
+
wildcard: true,
|
|
126
|
+
allowLocalhost: localhostDomain,
|
|
127
|
+
allowPort: true,
|
|
128
|
+
allowProtocol: true,
|
|
129
|
+
topLevel: false
|
|
130
|
+
});
|
|
131
|
+
let hasIgnoredExtension = false;
|
|
132
|
+
if (ignoreDomainExtensions) {
|
|
133
|
+
for (const ext of ignoreDomainExtensions) if (firstPart.endsWith(ext)) {
|
|
134
|
+
hasIgnoredExtension = true;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (isDomain && !hasIgnoredExtension) segments.shift();
|
|
139
|
+
return ensureLeadingSlash(segments.join("/"));
|
|
140
|
+
};
|
|
141
|
+
const ensureLeadingSlash = (path) => {
|
|
142
|
+
if (!path.startsWith("/")) path = "/" + path;
|
|
143
|
+
return path;
|
|
144
|
+
};
|
|
145
|
+
const throwError = (error) => {
|
|
146
|
+
const err = isError(error) ? error : /* @__PURE__ */ new Error("Unknown error from function `normalizePathname()`.");
|
|
147
|
+
throw new NormalizePathnameError(`Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`, err);
|
|
148
|
+
};
|
|
149
|
+
const formatEnvPort = (envVar, options = {}) => {
|
|
150
|
+
if (!isNonEmptyString(envVar)) return "";
|
|
151
|
+
assertIsPlainObject(options, { message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
152
|
+
const prefixColon = hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
|
|
153
|
+
if (!isBoolean(prefixColon)) throw new TypeError(`Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${getPreciseType(prefixColon)}\`.`);
|
|
154
|
+
const digitsOnly = envVar.replace(/\D+/g, "");
|
|
155
|
+
if (isEmptyString(digitsOnly)) return "";
|
|
156
|
+
return prefixColon ? `:${digitsOnly}` : digitsOnly;
|
|
157
|
+
};
|
|
158
|
+
export { normalizePathname as n, formatEnvPort as t };
|
|
159
|
+
//# sourceMappingURL=formatEnvPort-DpIXzPAZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatEnvPort-DpIXzPAZ.js","names":[],"sources":["../src/urls/_private/NormalizePathnameError.ts","../src/urls/pathname/normalizePathname.ts","../src/urls/utils/formatEnvPort.ts"],"sourcesContent":["import { isFunction } from \"@/predicates/is/isFunction\";\n\n/** ---------------------------------\n * * ***Custom Error for Pathname Normalization Failures***\n * --------------------------------- */\nexport class NormalizePathnameError extends Error {\n /** * ***The original error that triggered this normalization failure.***\n *\n * **Always available for backward compatibility.**\n */\n public readonly originalError: Error;\n\n constructor(message: string, originalError: Error) {\n // Pass a `cause` option if the runtime supports it (ignored by older engines).\n super(message, isFunction(Error) ? { cause: originalError } : undefined);\n\n this.name = \"NormalizePathnameError\";\n this.originalError = originalError;\n\n // Preserve stack trace when available (Node.js & modern browsers).\n if (isFunction(Error.captureStackTrace)) {\n Error.captureStackTrace(this, NormalizePathnameError);\n } else {\n // Fallback for very old environments.\n this.stack = new Error(message).stack;\n }\n }\n\n /** * ***Safe JSON representation for logging or IPC.*** */\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n stack: this.stack,\n originalError: {\n name: this.originalError.name,\n message: this.originalError.message,\n stack: this.originalError.stack\n }\n };\n }\n}\n","import type { OverrideTypes, Prettify } from \"@rzl-zone/ts-types-plus\";\n\nimport { isSet } from \"@/predicates/is/isSet\";\nimport { isNil } from \"@/predicates/is/isNil\";\nimport { isNull } from \"@/predicates/is/isNull\";\nimport { isArray } from \"@/predicates/is/isArray\";\nimport { isError } from \"@/predicates/is/isError\";\nimport { isString } from \"@/predicates/is/isString\";\nimport { isValidDomain } from \"@/predicates/is/isValidDomain\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\nimport { removeSpaces } from \"@/strings/sanitizations/removeSpaces\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\nimport { NormalizePathnameError } from \"../_private/NormalizePathnameError\";\nimport { isUndefined } from \"@/predicates/is/isUndefined\";\n\n/** Options when `keepNullable` is false (default).\n *\n * Returns `defaultPath` if `pathname` is empty or invalid.\n */\ntype UnKeepNullableOptions = {\n /** * ***Fallback value returned if `pathname` is empty-string or invalid.***\n *\n * Must be a **`non-empty string`**, defaultValue: `\"/\"`.\n *\n * @defaultValue `\"/\"`.\n */\n defaultPath?: string;\n\n /** * ***Whether to preserve `null` or `undefined`, defaultValue: `false`.***\n *\n * @defaultValue `false`.\n */\n keepNullable?: false;\n};\n\n/** Options when `keepNullable` is true.\n *\n * Preserves `null` or `undefined` instead of returning `defaultPath`.\n */\ntype KeepNullableOptions = {\n /** * ***Fallback path is ignored when `keepNullable` is true **(except if\n * `pathname` is empty-string or invalid, even this `true`)**,\n * defaultValue: `\"/\"`.***\n *\n * @defaultValue `\"/\"`.\n */\n defaultPath?: string;\n\n /** * ***Preserve `null` or `undefined` as-is if `true` (defaultValue: `false`).***\n *\n * - ***⚠️ Notes:***\n * - Keep returning `defaultPath` if `pathname` is empty-string, even this `true`.\n *\n * **Must be `true` in this type.**\n */\n keepNullable?: true;\n};\n\ntype MainNormalizePathnameOptions = {\n /** --------------------------------------------------------\n * * ***Preserve trailing slash at the end of the normalized pathname, defaultValue: `false`.***\n * --------------------------------------------------------\n *\n * @defaultValue `false`\n */\n keepTrailingSlash?: boolean;\n\n /** --------------------------------------------------------\n * * ***Allow special localhost domain at the beginning of the pathname.***\n * --------------------------------------------------------\n * @description\n * If `true`, the first segment of the pathname that is `/localhost` or `localhost`\n * (with or without a port, e.g., `localhost:3000`) will be treated as a special domain\n * and **removed** from the normalized pathname.\n *\n * - **Examples (`localhostDomain: true`)**:\n * - `\"/localhost/path\"` ➔ `\"/path\"`\n * - `\"localhost:3000/path\"` ➔ `\"/path\"`\n * - `\"localhost\"` ➔ `\"/\"` (entire path removed)\n *\n * - Only the **first path segment** is affected. Any subsequent occurrences of `\"localhost\"`\n * will remain intact.\n *\n * @defaultValue `false`\n */\n localhostDomain?: boolean;\n\n /**\n * --------------------------------------------------------\n * * ***Custom list of file extensions that prevent the first path segment from being treated as a domain.***\n * --------------------------------------------------------\n *\n * **Description:**\n * - The first segment of a pathname is often interpreted as a domain (e.g., `example.com`).\n * - If this first segment ends with any of the extensions listed here, it will **not** be considered a domain,\n * and will instead be preserved as part of the relative path.\n * - This is useful for cases where filenames appear at the start of a path and you want them treated as relative paths,\n * such as `\"image.png?version=2\"` or `\"archive.tar.gz#download\"`.\n * - Only the **first path segment** is affected; all other segments are processed normally.\n * - **Ignored** if:\n * 1. The pathname starts with a full URL protocol (`http://` or `https://`), e.g., `\"https://example.com/file.png\"`.\n * 2. The first path segment is already a valid domain, e.g., `\"example.com/image.png\"`.\n *\n * **Type & Validation:**\n * - Must be a `Set<string>` or `string[]`.\n * - Each string **must include the leading dot**, e.g., `.png`, `.tar.gz`.\n * - Multi-part extensions (like `.tar.gz`, `.tar.bz`) are supported.\n * - Throws a **TypeError** if:\n * 1. The type is not a `Set<string>` or `string[]`.\n * 2. Any string in the array/set is empty.\n * 3. Any string does not start with a dot (`.`).\n *\n * **Usage Notes:**\n * - Only applied when the first segment is otherwise domain-like **and** pathname is relative or domain-like without protocol.\n * - Query strings (`?x=1`) and hash fragments (`#section`) are preserved.\n *\n * **Examples (relative paths, option active):**\n * ```ts\n * normalizePathname(\"image.png?version=2\", {\n * ignoreDomainExtensions: [\".png\", \".jpg\"]\n * });\n * // ➔ \"/image.png?version=2\"\n *\n * normalizePathname(\"archive.tar.gz#download\", {\n * ignoreDomainExtensions: new Set([\".tar.gz\"])\n * });\n * // ➔ \"/archive.tar.gz#download\"\n *\n * normalizePathname(\"script.js?module=true#top\", {\n * ignoreDomainExtensions: [\".js\"]\n * });\n * // ➔ \"/script.js?module=true#top\"\n * ```\n *\n * **Examples (full URL or explicit domain - option ignored):**\n * ```ts\n * normalizePathname(\"https://example.com/image.png?version=2\", {\n * ignoreDomainExtensions: [\".png\"]\n * });\n * // ➔ \"/image.png?version=2\" // URL is parsed normally; ignoreDomainExtensions has no effect\n *\n * normalizePathname(\"example.com/script.js?module=true#top\", {\n * ignoreDomainExtensions: [\".js\"]\n * });\n * // ➔ \"/script.js?module=true#top\" // domain recognized; option ignored\n * ```\n *\n * **Notes:**\n * - Only the **first path segment** is checked.\n * - Prevents false-positive domain stripping for filenames that look like domains.\n * - Throws **TypeError** if invalid type or invalid string is provided.\n *\n * @defaultValue `undefined` (feature inactive if not provided)\n */\n ignoreDomainExtensions?: Set<string> | string[];\n};\n\n/** Options for main `normalizePathname`.\n *\n * Combines `UnKeepNullableOptions` or `KeepNullableOptions` with trailing slash control.\n */\ntype NormalizePathnameOptions = Prettify<\n MainNormalizePathnameOptions & (UnKeepNullableOptions | KeepNullableOptions)\n>;\n\ntype NormalizePathnameOptionsKeepNullableTrue = MainNormalizePathnameOptions &\n KeepNullableOptions;\ntype NormalizePathnameOptionsKeepNullableFalse = MainNormalizePathnameOptions &\n UnKeepNullableOptions;\n\ntype ResUnKeepNullable<T> = T extends undefined\n ? string\n : T extends null\n ? string\n : T extends null | undefined\n ? string\n : string;\n\ntype ResKeepNullable<T> = T extends string\n ? string\n : T extends undefined\n ? undefined\n : T extends null\n ? null\n : T extends null | undefined\n ? null | undefined\n : string | null | undefined;\n\n/** --------------------------------------------------------\n * * ***Utility: `normalizePathname`.***\n * --------------------------------------------------------\n *\n * - **Description:**\n * Normalizes any pathname or URL string to a clean, predictable format.\n * Useful for routing, file paths, and URL handling.\n * - Handles:\n * - Leading/trailing spaces\n * - Internal spaces in path segments\n * - Redundant slashes (`//`)\n * - Full URLs vs relative paths\n * - Query (`?`) and hash (`#`) preservation\n * - Unicode & emoji characters\n * - Optional nullable preservation (`keepNullable`)\n * - Optional trailing slash preservation (`keepTrailingSlash`)\n * - Optional removal of localhost first segment (`localhostDomain`)\n * - Prevention of false-positive domain stripping (`ignoreDomainExtensions`)\n *\n * - **Key Steps Internally:**\n * 1. Validate `options` (plain object, correct types)\n * 2. Validate `defaultPath` (non-empty string if `keepNullable` is false)\n * 3. Validate `ignoreDomainExtensions` (Set<string> | string[], each starts with `.`)\n * 4. Handle nullable:\n * - Returns `null` / `undefined` if `keepNullable: true`\n * - Otherwise uses `defaultPath`\n * 5. Trim spaces, remove internal spaces\n * 6. If full URL: parse using `URL` constructor\n * 7. If relative path or domain-like:\n * - Remove `localhost`/`localhost:port` if `localhostDomain`\n * - Remove first segment if domain-like and **not** in `ignoreDomainExtensions`\n * 8. Normalize slashes\n * 9. Ensure leading slash\n * 10. Handle trailing slash\n * 11. Decode Unicode safely\n * 12. Return normalized pathname + search + hash\n *\n * - **Error Handling:**\n * - **TypeError**:\n * - `defaultPath` invalid (non-string or empty) when `keepNullable: false`\n * - `keepNullable`, `keepTrailingSlash`, `localhostDomain` not boolean\n * - `ignoreDomainExtensions` invalid\n * - **NormalizePathnameError** (extends ***Error***):\n * - Invalid URL parsing\n * - Unexpected normalization errors\n *\n * - **Options:**\n * ```ts\n * {\n * // fallback if invalid path, default: \"/\"\n * defaultPath?: string;\n * // preserve null/undefined, default: false\n * keepNullable?: boolean;\n * // preserve trailing slash, default: false\n * keepTrailingSlash?: boolean;\n * // remove localhost:port first segment, default: false\n * localhostDomain?: boolean;\n * // prevent domain stripping, default: undefined\n * ignoreDomainExtensions?: Set<string> | string[];\n * }\n * ```\n *\n * @example\n * // Basic path cleaning\n * normalizePathname(\" /foo//bar \");\n * // ➔ \"/foo/bar\"\n *\n * // Trailing slash control\n * normalizePathname(\"/api//v1//user//\", { keepTrailingSlash: true });\n * // ➔ \"/api/v1/user/\"\n * normalizePathname(\"/api//v1//user//\", { keepTrailingSlash: false });\n * // ➔ \"/api/v1/user\"\n *\n * // Full URL normalization\n * normalizePathname(\"https://example.com//path///to/resource?x=1#hash\");\n * // ➔ \"/path/to/resource?x=1#hash\"\n *\n * // Null/undefined preservation\n * normalizePathname(null, { keepNullable: true });\n * // ➔ null\n * normalizePathname(undefined, { keepNullable: true });\n * // ➔ undefined\n *\n * // Default fallback\n * normalizePathname(\"\", { defaultPath: \"/home\" });\n * // ➔ \"/home\"\n *\n * // Localhost removal\n * normalizePathname(\"localhost:3000/path/to/resource\", { localhostDomain: true });\n * // ➔ \"/path/to/resource\"\n *\n * // Prevent false-positive domain stripping\n * normalizePathname(\"archive.tar.gz#download\", { ignoreDomainExtensions: [\".tar.gz\"] });\n * // ➔ \"/archive.tar.gz#download\"\n * normalizePathname(\"image.png?version=2\", { ignoreDomainExtensions: [\".png\"] });\n * // ➔ \"/image.png?version=2\"\n *\n * // Emojis and Unicode\n * normalizePathname(\"🔥//deep//path///🚀\");\n * // ➔ \"/🔥/deep/path/🚀\"\n *\n * // Query-only or hash-only\n * normalizePathname(\"?page=2\");\n * // ➔ \"/?page=2\"\n * normalizePathname(\"#section3\");\n * // ➔ \"/#section3\"\n *\n * // Complex nested paths\n * normalizePathname(\" //nested///folder//file.txt \");\n * // ➔ \"/nested/folder/file.txt\"\n *\n * // Invalid URL triggers error\n * try {\n * normalizePathname(\"http://\");\n * } catch (e) {\n * // console.log(e);\n * }\n *\n * // First segment is domain but ignored due to extension\n * normalizePathname(\"example.tar.bz/file\", { ignoreDomainExtensions: [\".tar.bz\"] });\n * // ➔ \"/example.tar.bz/file\"\n */\nexport function normalizePathname<T>(\n pathname: T,\n options?: NormalizePathnameOptionsKeepNullableFalse\n): ResUnKeepNullable<T>;\nexport function normalizePathname<T>(\n pathname: T,\n options?: NormalizePathnameOptionsKeepNullableTrue\n): ResKeepNullable<T>;\nexport function normalizePathname(\n pathname: unknown,\n options: NormalizePathnameOptions = {\n defaultPath: \"/\",\n keepNullable: false\n }\n): string | null | undefined {\n assertIsPlainObject(options, {\n message({ currentType, validType }) {\n return `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const {\n defaultPath = \"/\",\n keepNullable = false,\n keepTrailingSlash = false,\n localhostDomain = false,\n ignoreDomainExtensions = undefined\n } = options;\n\n // Validate defaultPath\n if (!isNonEmptyString(defaultPath)) {\n throw new TypeError(\n `Parameter \\`defaultPath\\` property of the \\`options\\` (second parameter) must be of type \\`string\\` and not empty-string, but received: \\`${getPreciseType(\n defaultPath\n )}\\`, with value: \\`${safeStableStringify(defaultPath, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n assertIsBoolean(keepNullable, {\n message({ currentType, validType }) {\n return `Parameter \\`keepNullable\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n assertIsBoolean(keepTrailingSlash, {\n message({ currentType, validType }) {\n return `Parameter \\`keepTrailingSlash\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n assertIsBoolean(localhostDomain, {\n message({ currentType, validType }) {\n return `Parameter \\`localhostDomain\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n let ignoreDomainExtsSet: Set<string> | undefined;\n\n if (!isUndefined(ignoreDomainExtensions)) {\n if (!isSet(ignoreDomainExtensions) && !isArray(ignoreDomainExtensions)) {\n throw new TypeError(\n `Parameter \\`ignoreDomainExtensions\\` must be of type a \\`Set<string>\\` or \\`string[]\\`, but received: \\`${getPreciseType(\n ignoreDomainExtensions\n )}\\`.`\n );\n }\n\n ignoreDomainExtsSet = isSet(ignoreDomainExtensions)\n ? ignoreDomainExtensions\n : new Set(ignoreDomainExtensions);\n\n // validation every ext\n let idx = 0;\n for (const ext of ignoreDomainExtsSet) {\n if (!isNonEmptyString(ext)) {\n throw new TypeError(\n `Parameter \\`ignoreDomainExtensions[${idx}]\\` must be a \\`string\\` and \\`non-empty string\\`, but received: \\`${safeStableStringify(\n ext,\n { keepUndefined: true }\n )}\\`.`\n );\n }\n if (!ext.startsWith(\".\")) {\n throw new TypeError(\n `Parameter \\`ignoreDomainExtensions[${idx}]\\` must start with a dot (.), but received: ${safeStableStringify(\n ext,\n { keepUndefined: true }\n )}`\n );\n }\n idx++;\n }\n }\n\n try {\n if (keepNullable && (isNil(pathname) || !isString(pathname))) {\n if (isNull(pathname)) return null;\n return undefined;\n }\n\n // If the pathname is invalid (null, undefined, or an empty string), return the default value, only if `keepNullable` is false\n let currentPathName: string = isNonEmptyString(pathname)\n ? pathname\n : defaultPath;\n\n // Trim spaces from the string (only trim leading and trailing spaces)\n currentPathName = removeSpaces(currentPathName, { trimOnly: true }).replace(\n /\\s+/g,\n \"\"\n ); // remove all space\n\n currentPathName = stripLeadingDomain(currentPathName, {\n keepTrailingSlash,\n localhostDomain,\n ignoreDomainExtensions: ignoreDomainExtsSet\n });\n\n let _pathName: string = currentPathName;\n let search = \"\";\n let hash = \"\";\n\n // relative path: extract search/hash manually\n const searchIndex = currentPathName.indexOf(\"?\");\n const hashIndex = currentPathName.indexOf(\"#\");\n\n if (searchIndex !== -1) {\n search = currentPathName.slice(\n searchIndex,\n hashIndex !== -1 ? hashIndex : undefined\n );\n }\n if (hashIndex !== -1) {\n hash = currentPathName.slice(hashIndex);\n }\n\n const endIndex = Math.min(\n searchIndex !== -1 ? searchIndex : currentPathName.length,\n hashIndex !== -1 ? hashIndex : currentPathName.length\n );\n _pathName = currentPathName.slice(0, endIndex);\n\n // Normalize slashes\n _pathName = \"/\" + _pathName.replace(/^\\/+/, \"\").replace(/\\/{2,}/g, \"/\");\n\n // Trailing slash\n // if (keepTrailingSlash && _pathName !== \"/\") {\n // _pathName += \"/\"\n // } else\n if (!keepTrailingSlash && _pathName !== \"/\") {\n _pathName = _pathName.replace(/\\/+$/, \"\");\n }\n\n // Decode Unicode safely\n _pathName = decodeUnicodeSequences(_pathName);\n search = decodeUnicodeSequences(search);\n hash = decodeUnicodeSequences(hash);\n\n return _pathName + search + hash;\n } catch (error) {\n // Handle any errors that occur during processing\n throwError(error);\n }\n}\n\n// --- Internal Helper Utils ----\n\n/** @internal */\nconst decodeUnicodeSequences = (str: string): string => {\n return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {\n try {\n const decoded = decodeURIComponent(match);\n // eslint-disable-next-line no-control-regex\n if (/^[\\u0000-\\u007F]+$/.test(decoded)) return match;\n // eslint-enable-next-line no-control-regex\n return decoded;\n } catch {\n return match;\n }\n });\n};\n/** @internal */\nconst stripLeadingDomain = (\n path: string,\n options: OverrideTypes<\n MainNormalizePathnameOptions,\n { ignoreDomainExtensions?: Set<string> }\n >\n): string => {\n let currentPath = path;\n\n const { ignoreDomainExtensions, localhostDomain } = options;\n\n // Full URL (protocol) -> only normalize path, ignore ignoreDomainExtensions\n if (/^https?:\\/\\//i.test(currentPath)) {\n try {\n const url = new URL(currentPath);\n currentPath =\n url.pathname.replace(/^\\/+/, \"\").replace(/\\/{2,}/g, \"/\") +\n url.search +\n url.hash;\n\n return ensureLeadingSlash(currentPath);\n } catch (error) {\n // fallback: keep as-is\n // Handle any errors that occur during processing\n throwError(error);\n }\n }\n\n // relative path: remove leading slash\n if (currentPath.startsWith(\"/\")) {\n currentPath = currentPath.replace(/\\/{2,}/g, \"/\").slice(1);\n }\n\n // take first segment\n const segments = currentPath.split(\"/\");\n const firstPart = segments[0];\n const domainPart = firstPart.split(\":\")[0];\n\n const isDomain = isValidDomain(domainPart, {\n subdomain: true,\n allowUnicode: true,\n wildcard: true,\n allowLocalhost: localhostDomain,\n allowPort: true,\n allowProtocol: true,\n topLevel: false\n });\n\n // ignoreDomainExtensions only applies for relative/non-protocol paths\n let hasIgnoredExtension = false;\n if (ignoreDomainExtensions) {\n for (const ext of ignoreDomainExtensions) {\n if (firstPart.endsWith(ext)) {\n hasIgnoredExtension = true;\n break;\n }\n }\n }\n\n if (isDomain && !hasIgnoredExtension) {\n segments.shift(); // remove first segment\n }\n\n return ensureLeadingSlash(segments.join(\"/\"));\n};\n/** @internal */\nconst ensureLeadingSlash = (path: string): string => {\n if (!path.startsWith(\"/\")) path = \"/\" + path;\n return path;\n};\n/** @internal */\nconst throwError = (error: unknown): never => {\n // Handle any errors that occur during processing\n const err = isError(error)\n ? error\n : new Error(\"Unknown error from function `normalizePathname()`.\");\n throw new NormalizePathnameError(\n `Failed to normalize pathname in function \\`normalizePathname()\\`: ${err.message}`,\n err\n );\n};\n","import { isBoolean } from \"@/predicates/is/isBoolean\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isEmptyString } from \"@/predicates/is/isEmptyString\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\ntype FormatEnvPortOptions = {\n /** Add prefix with a colon, defaultValue: `false`.\n *\n * @default false\n */\n prefixColon?: boolean;\n};\n\n/** -----------------------------------------------\n * * ***Utility: `formatEnvPort`.***\n * -----------------------------------------------\n * **Retrieves and formats an environment port variable.**\n * - **Behavior:**\n * - Extracts only digits from the input.\n * - If no digits found, returns an empty string.\n * - By default does NOT prefix with a colon.\n * - Use `{ prefixColon: true }` to prefix with a colon.\n * @param {string | null | undefined} envVar The environment variable string.\n * @param {FormatEnvPortOptions} [options] Optional object: `{ prefixColon?: boolean }`.\n * @returns {string} A string like `\":8080\"` or `\"8080\"`, or `\"\"` if no digits.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or `prefixColon` is not boolean.\n * @example\n * formatEnvPort(\"port:8080\");\n * // ➔ \"8080\"\n * formatEnvPort(\"port:8080\", { prefixColon: true });\n * // ➔ \":8080\"\n */\nexport const formatEnvPort = (\n envVar: string | null | undefined,\n options: FormatEnvPortOptions = {}\n): string => {\n if (!isNonEmptyString(envVar)) return \"\"; // Handle empty string case\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const prefixColon = hasOwnProp(options, \"prefixColon\")\n ? options.prefixColon\n : false;\n\n if (!isBoolean(prefixColon)) {\n throw new TypeError(\n `Parameter \\`prefixColon\\` property of the \\`options\\` (second parameter) must be of type \\`boolean\\`, but received: \\`${getPreciseType(\n prefixColon\n )}\\`.`\n );\n }\n\n const digitsOnly = envVar.replace(/\\D+/g, \"\");\n if (isEmptyString(digitsOnly)) return \"\";\n\n return prefixColon ? `:${digitsOnly}` : digitsOnly;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKA,IAAa,yBAAb,MAAa,+BAA+B,MAAM;;;;;CAKhD,AAAgB;CAEhB,YAAY,SAAiB,eAAsB;EAEjD,MAAM,SAAS,WAAW,MAAM,GAAG,EAAE,OAAO,eAAe,GAAG,OAAU;EAExE,KAAK,OAAO;EACZ,KAAK,gBAAgB;EAGrB,IAAI,WAAW,MAAM,kBAAkB,EACrC,MAAM,kBAAkB,MAAM,uBAAuB;OAGrD,KAAK,QAAQ,IAAI,MAAM,QAAQ,CAAC;;;CAKpC,SAAS;EACP,OAAO;GACL,MAAM,KAAK;GACX,SAAS,KAAK;GACd,OAAO,KAAK;GACZ,eAAe;IACb,MAAM,KAAK,cAAc;IACzB,SAAS,KAAK,cAAc;IAC5B,OAAO,KAAK,cAAc;IAC3B;GACF;;;;;;AC4RL,SAAgB,kBACd,UACA,UAAoC;CAClC,aAAa;CACb,cAAc;CACf,EAC0B;CAC3B,oBAAoB,SAAS,EAC3B,QAAQ,EAAE,aAAa,aAAa;EAClC,OAAO,oDAAoD,UAAU,sBAAsB,YAAY;IAE1G,CAAC;CAEF,MAAM,EACJ,cAAc,KACd,eAAe,OACf,oBAAoB,OACpB,kBAAkB,OAClB,yBAAyB,WACvB;CAGJ,IAAI,CAAC,iBAAiB,YAAY,EAChC,MAAM,IAAI,UACR,6IAA6I,eAC3I,YACD,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
|
2
|
+
* ========================================================================
|
|
3
|
+
* @rzl-zone/utils-js
|
|
4
|
+
* ------------------------------------------------------------------------
|
|
5
|
+
* Version: `3.12.1-beta.0`
|
|
6
|
+
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
|
+
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
|
+
* ========================================================================
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
const require_assertIsBoolean = require('./assertIsBoolean-DozdtbNi.cjs');
|
|
12
|
+
const require_safeStableStringify = require('./safeStableStringify-Cc62pfRp.cjs');
|
|
13
|
+
const require_isEmptyString = require('./isEmptyString-CCK3bP74.cjs');
|
|
14
|
+
const require_isValidDomain = require('./isValidDomain-BSXshgkC.cjs');
|
|
15
|
+
const require_removeSpaces = require('./removeSpaces-DRRxNWlb.cjs');
|
|
16
|
+
var NormalizePathnameError = class NormalizePathnameError extends Error {
|
|
17
|
+
originalError;
|
|
18
|
+
constructor(message, originalError) {
|
|
19
|
+
super(message, require_assertIsBoolean.isFunction(Error) ? { cause: originalError } : void 0);
|
|
20
|
+
this.name = "NormalizePathnameError";
|
|
21
|
+
this.originalError = originalError;
|
|
22
|
+
if (require_assertIsBoolean.isFunction(Error.captureStackTrace)) Error.captureStackTrace(this, NormalizePathnameError);
|
|
23
|
+
else this.stack = new Error(message).stack;
|
|
24
|
+
}
|
|
25
|
+
toJSON() {
|
|
26
|
+
return {
|
|
27
|
+
name: this.name,
|
|
28
|
+
message: this.message,
|
|
29
|
+
stack: this.stack,
|
|
30
|
+
originalError: {
|
|
31
|
+
name: this.originalError.name,
|
|
32
|
+
message: this.originalError.message,
|
|
33
|
+
stack: this.originalError.stack
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function normalizePathname(pathname, options = {
|
|
39
|
+
defaultPath: "/",
|
|
40
|
+
keepNullable: false
|
|
41
|
+
}) {
|
|
42
|
+
require_assertIsBoolean.assertIsPlainObject(options, { message({ currentType, validType }) {
|
|
43
|
+
return `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
44
|
+
} });
|
|
45
|
+
const { defaultPath = "/", keepNullable = false, keepTrailingSlash = false, localhostDomain = false, ignoreDomainExtensions = void 0 } = options;
|
|
46
|
+
if (!require_assertIsBoolean.isNonEmptyString(defaultPath)) throw new TypeError(`Parameter \`defaultPath\` property of the \`options\` (second parameter) must be of type \`string\` and not empty-string, but received: \`${require_assertIsBoolean.getPreciseType(defaultPath)}\`, with value: \`${require_safeStableStringify.safeStableStringify(defaultPath, { keepUndefined: true })}\`.`);
|
|
47
|
+
require_assertIsBoolean.assertIsBoolean(keepNullable, { message({ currentType, validType }) {
|
|
48
|
+
return `Parameter \`keepNullable\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
49
|
+
} });
|
|
50
|
+
require_assertIsBoolean.assertIsBoolean(keepTrailingSlash, { message({ currentType, validType }) {
|
|
51
|
+
return `Parameter \`keepTrailingSlash\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
52
|
+
} });
|
|
53
|
+
require_assertIsBoolean.assertIsBoolean(localhostDomain, { message({ currentType, validType }) {
|
|
54
|
+
return `Parameter \`localhostDomain\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
55
|
+
} });
|
|
56
|
+
let ignoreDomainExtsSet;
|
|
57
|
+
if (!require_assertIsBoolean.isUndefined(ignoreDomainExtensions)) {
|
|
58
|
+
if (!require_assertIsBoolean.isSet(ignoreDomainExtensions) && !require_assertIsBoolean.isArray(ignoreDomainExtensions)) throw new TypeError(`Parameter \`ignoreDomainExtensions\` must be of type a \`Set<string>\` or \`string[]\`, but received: \`${require_assertIsBoolean.getPreciseType(ignoreDomainExtensions)}\`.`);
|
|
59
|
+
ignoreDomainExtsSet = require_assertIsBoolean.isSet(ignoreDomainExtensions) ? ignoreDomainExtensions : new Set(ignoreDomainExtensions);
|
|
60
|
+
let idx = 0;
|
|
61
|
+
for (const ext of ignoreDomainExtsSet) {
|
|
62
|
+
if (!require_assertIsBoolean.isNonEmptyString(ext)) throw new TypeError(`Parameter \`ignoreDomainExtensions[${idx}]\` must be a \`string\` and \`non-empty string\`, but received: \`${require_safeStableStringify.safeStableStringify(ext, { keepUndefined: true })}\`.`);
|
|
63
|
+
if (!ext.startsWith(".")) throw new TypeError(`Parameter \`ignoreDomainExtensions[${idx}]\` must start with a dot (.), but received: ${require_safeStableStringify.safeStableStringify(ext, { keepUndefined: true })}`);
|
|
64
|
+
idx++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
if (keepNullable && (require_assertIsBoolean.isNil(pathname) || !require_assertIsBoolean.isString(pathname))) {
|
|
69
|
+
if (require_assertIsBoolean.isNull(pathname)) return null;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let currentPathName = require_assertIsBoolean.isNonEmptyString(pathname) ? pathname : defaultPath;
|
|
73
|
+
currentPathName = require_removeSpaces.removeSpaces(currentPathName, { trimOnly: true }).replace(/\s+/g, "");
|
|
74
|
+
currentPathName = stripLeadingDomain(currentPathName, {
|
|
75
|
+
keepTrailingSlash,
|
|
76
|
+
localhostDomain,
|
|
77
|
+
ignoreDomainExtensions: ignoreDomainExtsSet
|
|
78
|
+
});
|
|
79
|
+
let _pathName = currentPathName;
|
|
80
|
+
let search = "";
|
|
81
|
+
let hash = "";
|
|
82
|
+
const searchIndex = currentPathName.indexOf("?");
|
|
83
|
+
const hashIndex = currentPathName.indexOf("#");
|
|
84
|
+
if (searchIndex !== -1) search = currentPathName.slice(searchIndex, hashIndex !== -1 ? hashIndex : void 0);
|
|
85
|
+
if (hashIndex !== -1) hash = currentPathName.slice(hashIndex);
|
|
86
|
+
const endIndex = Math.min(searchIndex !== -1 ? searchIndex : currentPathName.length, hashIndex !== -1 ? hashIndex : currentPathName.length);
|
|
87
|
+
_pathName = currentPathName.slice(0, endIndex);
|
|
88
|
+
_pathName = "/" + _pathName.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
|
|
89
|
+
if (!keepTrailingSlash && _pathName !== "/") _pathName = _pathName.replace(/\/+$/, "");
|
|
90
|
+
_pathName = decodeUnicodeSequences(_pathName);
|
|
91
|
+
search = decodeUnicodeSequences(search);
|
|
92
|
+
hash = decodeUnicodeSequences(hash);
|
|
93
|
+
return _pathName + search + hash;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
throwError(error);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const decodeUnicodeSequences = (str) => {
|
|
99
|
+
return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {
|
|
100
|
+
try {
|
|
101
|
+
const decoded = decodeURIComponent(match);
|
|
102
|
+
if (/^[\u0000-\u007F]+$/.test(decoded)) return match;
|
|
103
|
+
return decoded;
|
|
104
|
+
} catch {
|
|
105
|
+
return match;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const stripLeadingDomain = (path, options) => {
|
|
110
|
+
let currentPath = path;
|
|
111
|
+
const { ignoreDomainExtensions, localhostDomain } = options;
|
|
112
|
+
if (/^https?:\/\//i.test(currentPath)) try {
|
|
113
|
+
const url = new URL(currentPath);
|
|
114
|
+
currentPath = url.pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/") + url.search + url.hash;
|
|
115
|
+
return ensureLeadingSlash(currentPath);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
throwError(error);
|
|
118
|
+
}
|
|
119
|
+
if (currentPath.startsWith("/")) currentPath = currentPath.replace(/\/{2,}/g, "/").slice(1);
|
|
120
|
+
const segments = currentPath.split("/");
|
|
121
|
+
const firstPart = segments[0];
|
|
122
|
+
const domainPart = firstPart.split(":")[0];
|
|
123
|
+
const isDomain = require_isValidDomain.isValidDomain(domainPart, {
|
|
124
|
+
subdomain: true,
|
|
125
|
+
allowUnicode: true,
|
|
126
|
+
wildcard: true,
|
|
127
|
+
allowLocalhost: localhostDomain,
|
|
128
|
+
allowPort: true,
|
|
129
|
+
allowProtocol: true,
|
|
130
|
+
topLevel: false
|
|
131
|
+
});
|
|
132
|
+
let hasIgnoredExtension = false;
|
|
133
|
+
if (ignoreDomainExtensions) {
|
|
134
|
+
for (const ext of ignoreDomainExtensions) if (firstPart.endsWith(ext)) {
|
|
135
|
+
hasIgnoredExtension = true;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (isDomain && !hasIgnoredExtension) segments.shift();
|
|
140
|
+
return ensureLeadingSlash(segments.join("/"));
|
|
141
|
+
};
|
|
142
|
+
const ensureLeadingSlash = (path) => {
|
|
143
|
+
if (!path.startsWith("/")) path = "/" + path;
|
|
144
|
+
return path;
|
|
145
|
+
};
|
|
146
|
+
const throwError = (error) => {
|
|
147
|
+
const err = require_assertIsBoolean.isError(error) ? error : /* @__PURE__ */ new Error("Unknown error from function `normalizePathname()`.");
|
|
148
|
+
throw new NormalizePathnameError(`Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`, err);
|
|
149
|
+
};
|
|
150
|
+
const formatEnvPort = (envVar, options = {}) => {
|
|
151
|
+
if (!require_assertIsBoolean.isNonEmptyString(envVar)) return "";
|
|
152
|
+
require_assertIsBoolean.assertIsPlainObject(options, { message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
153
|
+
const prefixColon = require_assertIsBoolean.hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
|
|
154
|
+
if (!require_assertIsBoolean.isBoolean(prefixColon)) throw new TypeError(`Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${require_assertIsBoolean.getPreciseType(prefixColon)}\`.`);
|
|
155
|
+
const digitsOnly = envVar.replace(/\D+/g, "");
|
|
156
|
+
if (require_isEmptyString.isEmptyString(digitsOnly)) return "";
|
|
157
|
+
return prefixColon ? `:${digitsOnly}` : digitsOnly;
|
|
158
|
+
};
|
|
159
|
+
Object.defineProperty(exports, 'formatEnvPort', {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function () {
|
|
162
|
+
return formatEnvPort;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
Object.defineProperty(exports, 'normalizePathname', {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
get: function () {
|
|
168
|
+
return normalizePathname;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
//# sourceMappingURL=formatEnvPort-hHNvOim-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatEnvPort-hHNvOim-.cjs","names":["isFunction","isNonEmptyString","getPreciseType","safeStableStringify","isUndefined","isSet","isArray","isNil","isString","isNull","removeSpaces","isValidDomain","isError","isNonEmptyString","hasOwnProp","isBoolean","getPreciseType","isEmptyString"],"sources":["../src/urls/_private/NormalizePathnameError.ts","../src/urls/pathname/normalizePathname.ts","../src/urls/utils/formatEnvPort.ts"],"sourcesContent":["import { isFunction } from \"@/predicates/is/isFunction\";\n\n/** ---------------------------------\n * * ***Custom Error for Pathname Normalization Failures***\n * --------------------------------- */\nexport class NormalizePathnameError extends Error {\n /** * ***The original error that triggered this normalization failure.***\n *\n * **Always available for backward compatibility.**\n */\n public readonly originalError: Error;\n\n constructor(message: string, originalError: Error) {\n // Pass a `cause` option if the runtime supports it (ignored by older engines).\n super(message, isFunction(Error) ? { cause: originalError } : undefined);\n\n this.name = \"NormalizePathnameError\";\n this.originalError = originalError;\n\n // Preserve stack trace when available (Node.js & modern browsers).\n if (isFunction(Error.captureStackTrace)) {\n Error.captureStackTrace(this, NormalizePathnameError);\n } else {\n // Fallback for very old environments.\n this.stack = new Error(message).stack;\n }\n }\n\n /** * ***Safe JSON representation for logging or IPC.*** */\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n stack: this.stack,\n originalError: {\n name: this.originalError.name,\n message: this.originalError.message,\n stack: this.originalError.stack\n }\n };\n }\n}\n","import type { OverrideTypes, Prettify } from \"@rzl-zone/ts-types-plus\";\n\nimport { isSet } from \"@/predicates/is/isSet\";\nimport { isNil } from \"@/predicates/is/isNil\";\nimport { isNull } from \"@/predicates/is/isNull\";\nimport { isArray } from \"@/predicates/is/isArray\";\nimport { isError } from \"@/predicates/is/isError\";\nimport { isString } from \"@/predicates/is/isString\";\nimport { isValidDomain } from \"@/predicates/is/isValidDomain\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\nimport { removeSpaces } from \"@/strings/sanitizations/removeSpaces\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\nimport { NormalizePathnameError } from \"../_private/NormalizePathnameError\";\nimport { isUndefined } from \"@/predicates/is/isUndefined\";\n\n/** Options when `keepNullable` is false (default).\n *\n * Returns `defaultPath` if `pathname` is empty or invalid.\n */\ntype UnKeepNullableOptions = {\n /** * ***Fallback value returned if `pathname` is empty-string or invalid.***\n *\n * Must be a **`non-empty string`**, defaultValue: `\"/\"`.\n *\n * @defaultValue `\"/\"`.\n */\n defaultPath?: string;\n\n /** * ***Whether to preserve `null` or `undefined`, defaultValue: `false`.***\n *\n * @defaultValue `false`.\n */\n keepNullable?: false;\n};\n\n/** Options when `keepNullable` is true.\n *\n * Preserves `null` or `undefined` instead of returning `defaultPath`.\n */\ntype KeepNullableOptions = {\n /** * ***Fallback path is ignored when `keepNullable` is true **(except if\n * `pathname` is empty-string or invalid, even this `true`)**,\n * defaultValue: `\"/\"`.***\n *\n * @defaultValue `\"/\"`.\n */\n defaultPath?: string;\n\n /** * ***Preserve `null` or `undefined` as-is if `true` (defaultValue: `false`).***\n *\n * - ***⚠️ Notes:***\n * - Keep returning `defaultPath` if `pathname` is empty-string, even this `true`.\n *\n * **Must be `true` in this type.**\n */\n keepNullable?: true;\n};\n\ntype MainNormalizePathnameOptions = {\n /** --------------------------------------------------------\n * * ***Preserve trailing slash at the end of the normalized pathname, defaultValue: `false`.***\n * --------------------------------------------------------\n *\n * @defaultValue `false`\n */\n keepTrailingSlash?: boolean;\n\n /** --------------------------------------------------------\n * * ***Allow special localhost domain at the beginning of the pathname.***\n * --------------------------------------------------------\n * @description\n * If `true`, the first segment of the pathname that is `/localhost` or `localhost`\n * (with or without a port, e.g., `localhost:3000`) will be treated as a special domain\n * and **removed** from the normalized pathname.\n *\n * - **Examples (`localhostDomain: true`)**:\n * - `\"/localhost/path\"` ➔ `\"/path\"`\n * - `\"localhost:3000/path\"` ➔ `\"/path\"`\n * - `\"localhost\"` ➔ `\"/\"` (entire path removed)\n *\n * - Only the **first path segment** is affected. Any subsequent occurrences of `\"localhost\"`\n * will remain intact.\n *\n * @defaultValue `false`\n */\n localhostDomain?: boolean;\n\n /**\n * --------------------------------------------------------\n * * ***Custom list of file extensions that prevent the first path segment from being treated as a domain.***\n * --------------------------------------------------------\n *\n * **Description:**\n * - The first segment of a pathname is often interpreted as a domain (e.g., `example.com`).\n * - If this first segment ends with any of the extensions listed here, it will **not** be considered a domain,\n * and will instead be preserved as part of the relative path.\n * - This is useful for cases where filenames appear at the start of a path and you want them treated as relative paths,\n * such as `\"image.png?version=2\"` or `\"archive.tar.gz#download\"`.\n * - Only the **first path segment** is affected; all other segments are processed normally.\n * - **Ignored** if:\n * 1. The pathname starts with a full URL protocol (`http://` or `https://`), e.g., `\"https://example.com/file.png\"`.\n * 2. The first path segment is already a valid domain, e.g., `\"example.com/image.png\"`.\n *\n * **Type & Validation:**\n * - Must be a `Set<string>` or `string[]`.\n * - Each string **must include the leading dot**, e.g., `.png`, `.tar.gz`.\n * - Multi-part extensions (like `.tar.gz`, `.tar.bz`) are supported.\n * - Throws a **TypeError** if:\n * 1. The type is not a `Set<string>` or `string[]`.\n * 2. Any string in the array/set is empty.\n * 3. Any string does not start with a dot (`.`).\n *\n * **Usage Notes:**\n * - Only applied when the first segment is otherwise domain-like **and** pathname is relative or domain-like without protocol.\n * - Query strings (`?x=1`) and hash fragments (`#section`) are preserved.\n *\n * **Examples (relative paths, option active):**\n * ```ts\n * normalizePathname(\"image.png?version=2\", {\n * ignoreDomainExtensions: [\".png\", \".jpg\"]\n * });\n * // ➔ \"/image.png?version=2\"\n *\n * normalizePathname(\"archive.tar.gz#download\", {\n * ignoreDomainExtensions: new Set([\".tar.gz\"])\n * });\n * // ➔ \"/archive.tar.gz#download\"\n *\n * normalizePathname(\"script.js?module=true#top\", {\n * ignoreDomainExtensions: [\".js\"]\n * });\n * // ➔ \"/script.js?module=true#top\"\n * ```\n *\n * **Examples (full URL or explicit domain - option ignored):**\n * ```ts\n * normalizePathname(\"https://example.com/image.png?version=2\", {\n * ignoreDomainExtensions: [\".png\"]\n * });\n * // ➔ \"/image.png?version=2\" // URL is parsed normally; ignoreDomainExtensions has no effect\n *\n * normalizePathname(\"example.com/script.js?module=true#top\", {\n * ignoreDomainExtensions: [\".js\"]\n * });\n * // ➔ \"/script.js?module=true#top\" // domain recognized; option ignored\n * ```\n *\n * **Notes:**\n * - Only the **first path segment** is checked.\n * - Prevents false-positive domain stripping for filenames that look like domains.\n * - Throws **TypeError** if invalid type or invalid string is provided.\n *\n * @defaultValue `undefined` (feature inactive if not provided)\n */\n ignoreDomainExtensions?: Set<string> | string[];\n};\n\n/** Options for main `normalizePathname`.\n *\n * Combines `UnKeepNullableOptions` or `KeepNullableOptions` with trailing slash control.\n */\ntype NormalizePathnameOptions = Prettify<\n MainNormalizePathnameOptions & (UnKeepNullableOptions | KeepNullableOptions)\n>;\n\ntype NormalizePathnameOptionsKeepNullableTrue = MainNormalizePathnameOptions &\n KeepNullableOptions;\ntype NormalizePathnameOptionsKeepNullableFalse = MainNormalizePathnameOptions &\n UnKeepNullableOptions;\n\ntype ResUnKeepNullable<T> = T extends undefined\n ? string\n : T extends null\n ? string\n : T extends null | undefined\n ? string\n : string;\n\ntype ResKeepNullable<T> = T extends string\n ? string\n : T extends undefined\n ? undefined\n : T extends null\n ? null\n : T extends null | undefined\n ? null | undefined\n : string | null | undefined;\n\n/** --------------------------------------------------------\n * * ***Utility: `normalizePathname`.***\n * --------------------------------------------------------\n *\n * - **Description:**\n * Normalizes any pathname or URL string to a clean, predictable format.\n * Useful for routing, file paths, and URL handling.\n * - Handles:\n * - Leading/trailing spaces\n * - Internal spaces in path segments\n * - Redundant slashes (`//`)\n * - Full URLs vs relative paths\n * - Query (`?`) and hash (`#`) preservation\n * - Unicode & emoji characters\n * - Optional nullable preservation (`keepNullable`)\n * - Optional trailing slash preservation (`keepTrailingSlash`)\n * - Optional removal of localhost first segment (`localhostDomain`)\n * - Prevention of false-positive domain stripping (`ignoreDomainExtensions`)\n *\n * - **Key Steps Internally:**\n * 1. Validate `options` (plain object, correct types)\n * 2. Validate `defaultPath` (non-empty string if `keepNullable` is false)\n * 3. Validate `ignoreDomainExtensions` (Set<string> | string[], each starts with `.`)\n * 4. Handle nullable:\n * - Returns `null` / `undefined` if `keepNullable: true`\n * - Otherwise uses `defaultPath`\n * 5. Trim spaces, remove internal spaces\n * 6. If full URL: parse using `URL` constructor\n * 7. If relative path or domain-like:\n * - Remove `localhost`/`localhost:port` if `localhostDomain`\n * - Remove first segment if domain-like and **not** in `ignoreDomainExtensions`\n * 8. Normalize slashes\n * 9. Ensure leading slash\n * 10. Handle trailing slash\n * 11. Decode Unicode safely\n * 12. Return normalized pathname + search + hash\n *\n * - **Error Handling:**\n * - **TypeError**:\n * - `defaultPath` invalid (non-string or empty) when `keepNullable: false`\n * - `keepNullable`, `keepTrailingSlash`, `localhostDomain` not boolean\n * - `ignoreDomainExtensions` invalid\n * - **NormalizePathnameError** (extends ***Error***):\n * - Invalid URL parsing\n * - Unexpected normalization errors\n *\n * - **Options:**\n * ```ts\n * {\n * // fallback if invalid path, default: \"/\"\n * defaultPath?: string;\n * // preserve null/undefined, default: false\n * keepNullable?: boolean;\n * // preserve trailing slash, default: false\n * keepTrailingSlash?: boolean;\n * // remove localhost:port first segment, default: false\n * localhostDomain?: boolean;\n * // prevent domain stripping, default: undefined\n * ignoreDomainExtensions?: Set<string> | string[];\n * }\n * ```\n *\n * @example\n * // Basic path cleaning\n * normalizePathname(\" /foo//bar \");\n * // ➔ \"/foo/bar\"\n *\n * // Trailing slash control\n * normalizePathname(\"/api//v1//user//\", { keepTrailingSlash: true });\n * // ➔ \"/api/v1/user/\"\n * normalizePathname(\"/api//v1//user//\", { keepTrailingSlash: false });\n * // ➔ \"/api/v1/user\"\n *\n * // Full URL normalization\n * normalizePathname(\"https://example.com//path///to/resource?x=1#hash\");\n * // ➔ \"/path/to/resource?x=1#hash\"\n *\n * // Null/undefined preservation\n * normalizePathname(null, { keepNullable: true });\n * // ➔ null\n * normalizePathname(undefined, { keepNullable: true });\n * // ➔ undefined\n *\n * // Default fallback\n * normalizePathname(\"\", { defaultPath: \"/home\" });\n * // ➔ \"/home\"\n *\n * // Localhost removal\n * normalizePathname(\"localhost:3000/path/to/resource\", { localhostDomain: true });\n * // ➔ \"/path/to/resource\"\n *\n * // Prevent false-positive domain stripping\n * normalizePathname(\"archive.tar.gz#download\", { ignoreDomainExtensions: [\".tar.gz\"] });\n * // ➔ \"/archive.tar.gz#download\"\n * normalizePathname(\"image.png?version=2\", { ignoreDomainExtensions: [\".png\"] });\n * // ➔ \"/image.png?version=2\"\n *\n * // Emojis and Unicode\n * normalizePathname(\"🔥//deep//path///🚀\");\n * // ➔ \"/🔥/deep/path/🚀\"\n *\n * // Query-only or hash-only\n * normalizePathname(\"?page=2\");\n * // ➔ \"/?page=2\"\n * normalizePathname(\"#section3\");\n * // ➔ \"/#section3\"\n *\n * // Complex nested paths\n * normalizePathname(\" //nested///folder//file.txt \");\n * // ➔ \"/nested/folder/file.txt\"\n *\n * // Invalid URL triggers error\n * try {\n * normalizePathname(\"http://\");\n * } catch (e) {\n * // console.log(e);\n * }\n *\n * // First segment is domain but ignored due to extension\n * normalizePathname(\"example.tar.bz/file\", { ignoreDomainExtensions: [\".tar.bz\"] });\n * // ➔ \"/example.tar.bz/file\"\n */\nexport function normalizePathname<T>(\n pathname: T,\n options?: NormalizePathnameOptionsKeepNullableFalse\n): ResUnKeepNullable<T>;\nexport function normalizePathname<T>(\n pathname: T,\n options?: NormalizePathnameOptionsKeepNullableTrue\n): ResKeepNullable<T>;\nexport function normalizePathname(\n pathname: unknown,\n options: NormalizePathnameOptions = {\n defaultPath: \"/\",\n keepNullable: false\n }\n): string | null | undefined {\n assertIsPlainObject(options, {\n message({ currentType, validType }) {\n return `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n const {\n defaultPath = \"/\",\n keepNullable = false,\n keepTrailingSlash = false,\n localhostDomain = false,\n ignoreDomainExtensions = undefined\n } = options;\n\n // Validate defaultPath\n if (!isNonEmptyString(defaultPath)) {\n throw new TypeError(\n `Parameter \\`defaultPath\\` property of the \\`options\\` (second parameter) must be of type \\`string\\` and not empty-string, but received: \\`${getPreciseType(\n defaultPath\n )}\\`, with value: \\`${safeStableStringify(defaultPath, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n assertIsBoolean(keepNullable, {\n message({ currentType, validType }) {\n return `Parameter \\`keepNullable\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n assertIsBoolean(keepTrailingSlash, {\n message({ currentType, validType }) {\n return `Parameter \\`keepTrailingSlash\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n assertIsBoolean(localhostDomain, {\n message({ currentType, validType }) {\n return `Parameter \\`localhostDomain\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n let ignoreDomainExtsSet: Set<string> | undefined;\n\n if (!isUndefined(ignoreDomainExtensions)) {\n if (!isSet(ignoreDomainExtensions) && !isArray(ignoreDomainExtensions)) {\n throw new TypeError(\n `Parameter \\`ignoreDomainExtensions\\` must be of type a \\`Set<string>\\` or \\`string[]\\`, but received: \\`${getPreciseType(\n ignoreDomainExtensions\n )}\\`.`\n );\n }\n\n ignoreDomainExtsSet = isSet(ignoreDomainExtensions)\n ? ignoreDomainExtensions\n : new Set(ignoreDomainExtensions);\n\n // validation every ext\n let idx = 0;\n for (const ext of ignoreDomainExtsSet) {\n if (!isNonEmptyString(ext)) {\n throw new TypeError(\n `Parameter \\`ignoreDomainExtensions[${idx}]\\` must be a \\`string\\` and \\`non-empty string\\`, but received: \\`${safeStableStringify(\n ext,\n { keepUndefined: true }\n )}\\`.`\n );\n }\n if (!ext.startsWith(\".\")) {\n throw new TypeError(\n `Parameter \\`ignoreDomainExtensions[${idx}]\\` must start with a dot (.), but received: ${safeStableStringify(\n ext,\n { keepUndefined: true }\n )}`\n );\n }\n idx++;\n }\n }\n\n try {\n if (keepNullable && (isNil(pathname) || !isString(pathname))) {\n if (isNull(pathname)) return null;\n return undefined;\n }\n\n // If the pathname is invalid (null, undefined, or an empty string), return the default value, only if `keepNullable` is false\n let currentPathName: string = isNonEmptyString(pathname)\n ? pathname\n : defaultPath;\n\n // Trim spaces from the string (only trim leading and trailing spaces)\n currentPathName = removeSpaces(currentPathName, { trimOnly: true }).replace(\n /\\s+/g,\n \"\"\n ); // remove all space\n\n currentPathName = stripLeadingDomain(currentPathName, {\n keepTrailingSlash,\n localhostDomain,\n ignoreDomainExtensions: ignoreDomainExtsSet\n });\n\n let _pathName: string = currentPathName;\n let search = \"\";\n let hash = \"\";\n\n // relative path: extract search/hash manually\n const searchIndex = currentPathName.indexOf(\"?\");\n const hashIndex = currentPathName.indexOf(\"#\");\n\n if (searchIndex !== -1) {\n search = currentPathName.slice(\n searchIndex,\n hashIndex !== -1 ? hashIndex : undefined\n );\n }\n if (hashIndex !== -1) {\n hash = currentPathName.slice(hashIndex);\n }\n\n const endIndex = Math.min(\n searchIndex !== -1 ? searchIndex : currentPathName.length,\n hashIndex !== -1 ? hashIndex : currentPathName.length\n );\n _pathName = currentPathName.slice(0, endIndex);\n\n // Normalize slashes\n _pathName = \"/\" + _pathName.replace(/^\\/+/, \"\").replace(/\\/{2,}/g, \"/\");\n\n // Trailing slash\n // if (keepTrailingSlash && _pathName !== \"/\") {\n // _pathName += \"/\"\n // } else\n if (!keepTrailingSlash && _pathName !== \"/\") {\n _pathName = _pathName.replace(/\\/+$/, \"\");\n }\n\n // Decode Unicode safely\n _pathName = decodeUnicodeSequences(_pathName);\n search = decodeUnicodeSequences(search);\n hash = decodeUnicodeSequences(hash);\n\n return _pathName + search + hash;\n } catch (error) {\n // Handle any errors that occur during processing\n throwError(error);\n }\n}\n\n// --- Internal Helper Utils ----\n\n/** @internal */\nconst decodeUnicodeSequences = (str: string): string => {\n return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {\n try {\n const decoded = decodeURIComponent(match);\n // eslint-disable-next-line no-control-regex\n if (/^[\\u0000-\\u007F]+$/.test(decoded)) return match;\n // eslint-enable-next-line no-control-regex\n return decoded;\n } catch {\n return match;\n }\n });\n};\n/** @internal */\nconst stripLeadingDomain = (\n path: string,\n options: OverrideTypes<\n MainNormalizePathnameOptions,\n { ignoreDomainExtensions?: Set<string> }\n >\n): string => {\n let currentPath = path;\n\n const { ignoreDomainExtensions, localhostDomain } = options;\n\n // Full URL (protocol) -> only normalize path, ignore ignoreDomainExtensions\n if (/^https?:\\/\\//i.test(currentPath)) {\n try {\n const url = new URL(currentPath);\n currentPath =\n url.pathname.replace(/^\\/+/, \"\").replace(/\\/{2,}/g, \"/\") +\n url.search +\n url.hash;\n\n return ensureLeadingSlash(currentPath);\n } catch (error) {\n // fallback: keep as-is\n // Handle any errors that occur during processing\n throwError(error);\n }\n }\n\n // relative path: remove leading slash\n if (currentPath.startsWith(\"/\")) {\n currentPath = currentPath.replace(/\\/{2,}/g, \"/\").slice(1);\n }\n\n // take first segment\n const segments = currentPath.split(\"/\");\n const firstPart = segments[0];\n const domainPart = firstPart.split(\":\")[0];\n\n const isDomain = isValidDomain(domainPart, {\n subdomain: true,\n allowUnicode: true,\n wildcard: true,\n allowLocalhost: localhostDomain,\n allowPort: true,\n allowProtocol: true,\n topLevel: false\n });\n\n // ignoreDomainExtensions only applies for relative/non-protocol paths\n let hasIgnoredExtension = false;\n if (ignoreDomainExtensions) {\n for (const ext of ignoreDomainExtensions) {\n if (firstPart.endsWith(ext)) {\n hasIgnoredExtension = true;\n break;\n }\n }\n }\n\n if (isDomain && !hasIgnoredExtension) {\n segments.shift(); // remove first segment\n }\n\n return ensureLeadingSlash(segments.join(\"/\"));\n};\n/** @internal */\nconst ensureLeadingSlash = (path: string): string => {\n if (!path.startsWith(\"/\")) path = \"/\" + path;\n return path;\n};\n/** @internal */\nconst throwError = (error: unknown): never => {\n // Handle any errors that occur during processing\n const err = isError(error)\n ? error\n : new Error(\"Unknown error from function `normalizePathname()`.\");\n throw new NormalizePathnameError(\n `Failed to normalize pathname in function \\`normalizePathname()\\`: ${err.message}`,\n err\n );\n};\n","import { isBoolean } from \"@/predicates/is/isBoolean\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isEmptyString } from \"@/predicates/is/isEmptyString\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\ntype FormatEnvPortOptions = {\n /** Add prefix with a colon, defaultValue: `false`.\n *\n * @default false\n */\n prefixColon?: boolean;\n};\n\n/** -----------------------------------------------\n * * ***Utility: `formatEnvPort`.***\n * -----------------------------------------------\n * **Retrieves and formats an environment port variable.**\n * - **Behavior:**\n * - Extracts only digits from the input.\n * - If no digits found, returns an empty string.\n * - By default does NOT prefix with a colon.\n * - Use `{ prefixColon: true }` to prefix with a colon.\n * @param {string | null | undefined} envVar The environment variable string.\n * @param {FormatEnvPortOptions} [options] Optional object: `{ prefixColon?: boolean }`.\n * @returns {string} A string like `\":8080\"` or `\"8080\"`, or `\"\"` if no digits.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or `prefixColon` is not boolean.\n * @example\n * formatEnvPort(\"port:8080\");\n * // ➔ \"8080\"\n * formatEnvPort(\"port:8080\", { prefixColon: true });\n * // ➔ \":8080\"\n */\nexport const formatEnvPort = (\n envVar: string | null | undefined,\n options: FormatEnvPortOptions = {}\n): string => {\n if (!isNonEmptyString(envVar)) return \"\"; // Handle empty string case\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const prefixColon = hasOwnProp(options, \"prefixColon\")\n ? options.prefixColon\n : false;\n\n if (!isBoolean(prefixColon)) {\n throw new TypeError(\n `Parameter \\`prefixColon\\` property of the \\`options\\` (second parameter) must be of type \\`boolean\\`, but received: \\`${getPreciseType(\n prefixColon\n )}\\`.`\n );\n }\n\n const digitsOnly = envVar.replace(/\\D+/g, \"\");\n if (isEmptyString(digitsOnly)) return \"\";\n\n return prefixColon ? `:${digitsOnly}` : digitsOnly;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKA,IAAa,yBAAb,MAAa,+BAA+B,MAAM;;;;;CAKhD,AAAgB;CAEhB,YAAY,SAAiB,eAAsB;EAEjD,MAAM,SAASA,mCAAW,MAAM,GAAG,EAAE,OAAO,eAAe,GAAG,OAAU;EAExE,KAAK,OAAO;EACZ,KAAK,gBAAgB;EAGrB,IAAIA,mCAAW,MAAM,kBAAkB,EACrC,MAAM,kBAAkB,MAAM,uBAAuB;OAGrD,KAAK,QAAQ,IAAI,MAAM,QAAQ,CAAC;;;CAKpC,SAAS;EACP,OAAO;GACL,MAAM,KAAK;GACX,SAAS,KAAK;GACd,OAAO,KAAK;GACZ,eAAe;IACb,MAAM,KAAK,cA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