@rzl-zone/utils-js 3.8.0 → 3.9.1

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.
Files changed (122) hide show
  1. package/README.md +5 -1
  2. package/dist/assertions/index.cjs +11 -11
  3. package/dist/assertions/index.d.ts +168 -57
  4. package/dist/assertions/index.js +5 -5
  5. package/dist/{chunk-EK7FSI7F.cjs → chunk-2XGQQZ6A.cjs} +3 -3
  6. package/dist/{chunk-YS27V6LS.js → chunk-3LE6NX57.js} +5 -176
  7. package/dist/{chunk-PZQC3FZY.js → chunk-44X74C26.js} +4 -4
  8. package/dist/{chunk-4ACKNPL5.js → chunk-5KDVIEVO.js} +2 -2
  9. package/dist/{chunk-JY4HLZ4W.js → chunk-5O66AUEC.js} +2 -2
  10. package/dist/{chunk-SLP24LUV.js → chunk-5Y6JL47L.js} +3 -3
  11. package/dist/{chunk-ZW3VYES4.cjs → chunk-62FS7WMB.cjs} +31 -31
  12. package/dist/{chunk-VJVCXEH7.cjs → chunk-6AMDHVS2.cjs} +9 -181
  13. package/dist/{chunk-5IKZ3JDV.js → chunk-6WVOUVWD.js} +9 -9
  14. package/dist/{chunk-BYUT376O.cjs → chunk-76ATVDCR.cjs} +3 -3
  15. package/dist/{chunk-F3WBQKRI.cjs → chunk-7C7TQC5J.cjs} +29 -7
  16. package/dist/{chunk-I3IXLEEG.js → chunk-7EIFPHV3.js} +8 -8
  17. package/dist/{chunk-6RFNZ2ZZ.cjs → chunk-7NXFGJJE.cjs} +14 -14
  18. package/dist/{chunk-TFDXRT6D.cjs → chunk-ALRISPTL.cjs} +3 -3
  19. package/dist/chunk-BAV5T2E3.cjs +1 -1
  20. package/dist/{chunk-4ZOXSUXB.js → chunk-C7GC2PFX.js} +3 -3
  21. package/dist/chunk-DVMHRLKP.cjs +1 -1
  22. package/dist/{chunk-KVZ3HL2B.js → chunk-DXPM4NOU.js} +4 -4
  23. package/dist/{chunk-DPLL67OT.js → chunk-EJV5AF4L.js} +2 -2
  24. package/dist/{chunk-NREACG6M.cjs → chunk-FWWPEL7J.cjs} +3 -3
  25. package/dist/{chunk-LEX4TQW2.js → chunk-GHU356XQ.js} +4 -6
  26. package/dist/chunk-GKDSBOYE.js +209 -0
  27. package/dist/{chunk-YC7AK3KX.cjs → chunk-H44QVAZL.cjs} +31 -31
  28. package/dist/{chunk-AKKM6MOX.cjs → chunk-I33PB44Q.cjs} +15 -15
  29. package/dist/{chunk-LIU4S3JA.cjs → chunk-IX6PF5ZP.cjs} +4 -4
  30. package/dist/{chunk-3KTD3QDI.js → chunk-J4TT33ZX.js} +29 -7
  31. package/dist/{chunk-SZJ7OI4S.js → chunk-J6VLFVIL.js} +3 -3
  32. package/dist/{chunk-3JD53UUH.cjs → chunk-JI57K7D4.cjs} +161 -161
  33. package/dist/{chunk-OFBFGFVH.js → chunk-JYOCB6OV.js} +2 -2
  34. package/dist/chunk-KHO2SBNA.cjs +1 -1
  35. package/dist/{chunk-6NORJBI6.cjs → chunk-KUVRZ2JW.cjs} +50 -50
  36. package/dist/chunk-L5RDAVVH.js +1 -1
  37. package/dist/{chunk-VCVND6CH.js → chunk-M5QB2GM5.js} +2 -2
  38. package/dist/{chunk-RRJIRXHS.js → chunk-MBFVTGYS.js} +4 -4
  39. package/dist/{chunk-UKAUXY2U.cjs → chunk-MMRHKYT6.cjs} +12 -12
  40. package/dist/{chunk-U5VR4TJN.js → chunk-MS2KSKD7.js} +9 -9
  41. package/dist/{chunk-7ZNEUWYP.js → chunk-MZ3T6L7Z.js} +2 -2
  42. package/dist/{chunk-ATLFMKAF.cjs → chunk-NAOVH4OH.cjs} +7 -7
  43. package/dist/{chunk-HKJZ7K2K.cjs → chunk-NJ24M6ZH.cjs} +37 -37
  44. package/dist/chunk-OCTHWEZK.cjs +249 -0
  45. package/dist/chunk-ONZFBJVW.js +1 -1
  46. package/dist/{chunk-FI76UZRF.js → chunk-OSSFLQDD.js} +3 -4
  47. package/dist/{chunk-7WBMA2VE.cjs → chunk-OYFUBKEG.cjs} +4 -5
  48. package/dist/{chunk-B4SDEBN7.cjs → chunk-PWKOFPAH.cjs} +3 -3
  49. package/dist/{chunk-RJYWBVGD.cjs → chunk-QGTFQ7RO.cjs} +6 -6
  50. package/dist/chunk-QNKGP5DY.js +1 -1
  51. package/dist/chunk-QXTJVDWE.js +676 -0
  52. package/dist/{chunk-B6UIKBHR.cjs → chunk-QZI5PVCI.cjs} +4 -4
  53. package/dist/{chunk-PW2VMJLT.js → chunk-R2DR7SPJ.js} +99 -25
  54. package/dist/{chunk-TDYGYHSH.js → chunk-SN5HAK3Y.js} +4 -4
  55. package/dist/{chunk-P3ST4UZA.js → chunk-SRWL4YCP.js} +7 -7
  56. package/dist/{chunk-7QQV66RX.cjs → chunk-TJ5OY6MC.cjs} +10 -10
  57. package/dist/{chunk-6WMB5AJR.js → chunk-TXOVQZPU.js} +3 -4
  58. package/dist/chunk-UDA26MCU.cjs +1 -1
  59. package/dist/{chunk-LVFTN6DK.cjs → chunk-UFYMRRJH.cjs} +61 -61
  60. package/dist/{chunk-5NN4ZDE2.cjs → chunk-UV5BKAYW.cjs} +6 -8
  61. package/dist/{chunk-GAJBF6DR.js → chunk-UXT4XSUK.js} +2 -2
  62. package/dist/{chunk-6VA4F6VR.js → chunk-VBSLIIDB.js} +10 -10
  63. package/dist/chunk-VCYXNIZ2.cjs +678 -0
  64. package/dist/chunk-VJDDGRIK.cjs +1 -1
  65. package/dist/{chunk-JIROTDOU.js → chunk-WB3FT62A.js} +3 -3
  66. package/dist/{chunk-K63WO3XA.cjs → chunk-WKM6UVMG.cjs} +4 -5
  67. package/dist/{chunk-5PF7KRCP.cjs → chunk-WLEZ2KSG.cjs} +126 -126
  68. package/dist/{chunk-ZN53RM3R.js → chunk-WRGN6UBK.js} +2 -2
  69. package/dist/chunk-WVSPXFTY.js +1 -1
  70. package/dist/{chunk-2VO2CBTU.js → chunk-X6ULJZ3X.js} +2 -2
  71. package/dist/{chunk-CKUEZF4R.cjs → chunk-XYWC4EQ3.cjs} +71 -71
  72. package/dist/{chunk-A3YI6Y2P.js → chunk-YHFRCVTN.js} +3 -3
  73. package/dist/{chunk-A4H7474O.cjs → chunk-YQHJB7KR.cjs} +26 -26
  74. package/dist/{chunk-YGB2BQPB.cjs → chunk-YVRUY4EW.cjs} +8 -8
  75. package/dist/chunk-YWHHVDT4.js +1 -1
  76. package/dist/chunk-ZTHJQJ5F.cjs +211 -0
  77. package/dist/conversions/index.cjs +34 -34
  78. package/dist/conversions/index.d.ts +1 -1
  79. package/dist/conversions/index.js +15 -15
  80. package/dist/events/index.cjs +8 -8
  81. package/dist/events/index.d.ts +1 -1
  82. package/dist/events/index.js +4 -4
  83. package/dist/formatters/index.cjs +19 -19
  84. package/dist/formatters/index.d.ts +1 -1
  85. package/dist/formatters/index.js +9 -9
  86. package/dist/generators/index.cjs +9 -9
  87. package/dist/generators/index.d.ts +1 -1
  88. package/dist/generators/index.js +4 -4
  89. package/dist/index.d.ts +1 -1
  90. package/dist/isPlainObject-BTPjv6zB.d.ts +1 -1
  91. package/dist/next/index.cjs +37 -36
  92. package/dist/next/index.d.ts +1 -1
  93. package/dist/next/index.js +9 -8
  94. package/dist/next/server/index.cjs +4 -4
  95. package/dist/next/server/index.d.ts +1 -1
  96. package/dist/next/server/index.js +2 -2
  97. package/dist/operations/index.cjs +11 -11
  98. package/dist/operations/index.d.ts +1 -1
  99. package/dist/operations/index.js +8 -8
  100. package/dist/parsers/index.cjs +6 -4
  101. package/dist/parsers/index.d.ts +224 -32
  102. package/dist/parsers/index.js +5 -3
  103. package/dist/predicates/index.cjs +77 -76
  104. package/dist/predicates/index.d.ts +1 -1
  105. package/dist/predicates/index.js +14 -13
  106. package/dist/promises/index.cjs +6 -6
  107. package/dist/promises/index.d.ts +2 -3
  108. package/dist/promises/index.js +4 -4
  109. package/dist/rzl-utils.global.js +2 -2
  110. package/dist/strings/index.cjs +23 -23
  111. package/dist/strings/index.d.ts +1 -1
  112. package/dist/strings/index.js +7 -7
  113. package/dist/tailwind/index.cjs +13 -13
  114. package/dist/tailwind/index.d.ts +1 -1
  115. package/dist/tailwind/index.js +5 -5
  116. package/dist/urls/index.cjs +23 -21
  117. package/dist/urls/index.d.ts +182 -114
  118. package/dist/urls/index.js +16 -14
  119. package/package.json +1 -1
  120. package/dist/chunk-KPCDDYTZ.js +0 -417
  121. package/dist/chunk-QAPYHLHC.cjs +0 -419
  122. package/dist/chunk-SGCN4ED4.cjs +0 -175
@@ -1,419 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.8.0.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
13
-
14
- var KNOWN_EXTENSIONS = /* @__PURE__ */ new Set([
15
- // 📄 Text & Document
16
- "txt",
17
- "md",
18
- "rtf",
19
- "tex",
20
- "doc",
21
- "docx",
22
- "odt",
23
- "ott",
24
- "pdf",
25
- "djvu",
26
- "epub",
27
- "mobi",
28
- "azw",
29
- "azw3",
30
- "xls",
31
- "xlsx",
32
- "ods",
33
- "csv",
34
- "tsv",
35
- "ppt",
36
- "pptx",
37
- "odp",
38
- "pps",
39
- "md",
40
- "bib",
41
- "tex",
42
- "log",
43
- // 🖼️ Image
44
- "jpg",
45
- "jpeg",
46
- "png",
47
- "gif",
48
- "bmp",
49
- "tif",
50
- "tiff",
51
- "webp",
52
- "svg",
53
- "ico",
54
- "heif",
55
- "heic",
56
- "raw",
57
- "cr2",
58
- "nef",
59
- "orf",
60
- "sr2",
61
- "dng",
62
- "dds",
63
- "psd",
64
- "exr",
65
- "xcf",
66
- "ai",
67
- "eps",
68
- "cdr",
69
- "psd",
70
- "indd",
71
- // 🎵 Audio
72
- "mp3",
73
- "wav",
74
- "ogg",
75
- "flac",
76
- "aac",
77
- "m4a",
78
- "wma",
79
- "alac",
80
- "aiff",
81
- "amr",
82
- "mid",
83
- "midi",
84
- "opus",
85
- "au",
86
- "caf",
87
- "ape",
88
- "opus",
89
- // 🎥 Video
90
- "mp4",
91
- "mkv",
92
- "avi",
93
- "mov",
94
- "flv",
95
- "wmv",
96
- "webm",
97
- "mpeg",
98
- "mpg",
99
- "3gp",
100
- "3g2",
101
- "m4v",
102
- "ts",
103
- "mts",
104
- "asf",
105
- "rm",
106
- "rmvb",
107
- "vob",
108
- "f4v",
109
- "ogv",
110
- "m2ts",
111
- "mod",
112
- "dav",
113
- // 🗃️ Archive & Compression
114
- "zip",
115
- "rar",
116
- "7z",
117
- "tar",
118
- "gz",
119
- "bz2",
120
- "xz",
121
- "tgz",
122
- "tbz2",
123
- "txz",
124
- "lz",
125
- "lzma",
126
- "z",
127
- "cab",
128
- "arj",
129
- "ace",
130
- "iso",
131
- "dmg",
132
- "rpm",
133
- "deb",
134
- "pkg",
135
- "apk",
136
- "jar",
137
- // 💾 Disk Image
138
- "iso",
139
- "img",
140
- "vhd",
141
- "vmdk",
142
- "qcow2",
143
- "dmg",
144
- // 🗃️ Database & Data
145
- "sql",
146
- "db",
147
- "dbf",
148
- "mdb",
149
- "accdb",
150
- "json",
151
- "xml",
152
- "yaml",
153
- "yml",
154
- "toml",
155
- "ini",
156
- "plist",
157
- "yaml",
158
- "pkl",
159
- "msgpack",
160
- "h5",
161
- "hdf5",
162
- "parquet",
163
- "avro",
164
- "orc",
165
- "ndjson",
166
- "db",
167
- "pdb",
168
- "sqlite",
169
- "sqlite3",
170
- "dbx",
171
- "sdf",
172
- // 💻 Code & Script
173
- "js",
174
- "jsx",
175
- "ts",
176
- "tsx",
177
- "c",
178
- "cpp",
179
- "h",
180
- "hpp",
181
- "java",
182
- "py",
183
- "rb",
184
- "go",
185
- "rs",
186
- "php",
187
- "pl",
188
- "sh",
189
- "bat",
190
- "cmd",
191
- "ps1",
192
- "lua",
193
- "swift",
194
- "kt",
195
- "scala",
196
- "cs",
197
- "vb",
198
- "dart",
199
- "m",
200
- "r",
201
- "jl",
202
- "fs",
203
- "vbproj",
204
- "sln",
205
- "pri",
206
- "Makefile",
207
- // 🌐 Web & Config
208
- "html",
209
- "htm",
210
- "xhtml",
211
- "css",
212
- "scss",
213
- "sass",
214
- "less",
215
- "xml",
216
- "json",
217
- "yaml",
218
- "yml",
219
- "xlf",
220
- "xlf",
221
- "po",
222
- "pot",
223
- "jsp",
224
- "asp",
225
- "aspx",
226
- "php",
227
- "jspf",
228
- "cgi",
229
- "cfm",
230
- "pl",
231
- "env",
232
- "conf",
233
- "config",
234
- "xml",
235
- "ini",
236
- "cfg",
237
- "toml",
238
- "yaml",
239
- "dockerfile",
240
- "gitignore",
241
- "gitconfig",
242
- "gitattributes",
243
- "npmignore",
244
- "lock",
245
- "gradle",
246
- "pom",
247
- "yaml",
248
- "prettierrc",
249
- "eslintrc",
250
- "babelrc",
251
- "editorconfig",
252
- // 🔠 Font
253
- "ttf",
254
- "otf",
255
- "woff",
256
- "woff2",
257
- "eot",
258
- // 🗺️ CAD & GIS
259
- "dwg",
260
- "dxf",
261
- "shp",
262
- "kml",
263
- "kmz",
264
- "gpx",
265
- "stl",
266
- "step",
267
- "iges",
268
- "3ds",
269
- "3dm",
270
- "fbx",
271
- "obj",
272
- // 🔧 System / Binary / Execution
273
- "exe",
274
- "msi",
275
- "bin",
276
- "run",
277
- "com",
278
- "cmd",
279
- "apk",
280
- "app",
281
- "deb",
282
- "rpm",
283
- "elf",
284
- "dll",
285
- "so",
286
- "dylib",
287
- "sys",
288
- // 🔐 Certificates / Crypto
289
- "pem",
290
- "crt",
291
- "cer",
292
- "key",
293
- "der",
294
- "csr",
295
- "p12",
296
- "pfx",
297
- "jks",
298
- // 🎮 Games & Projects
299
- "iso",
300
- "cue",
301
- "bin",
302
- "nes",
303
- "sfc",
304
- "gba",
305
- "nds",
306
- "nes",
307
- "sav",
308
- "rom",
309
- "pak",
310
- "vpk",
311
- "bik",
312
- // 📚 E-books and Comics
313
- "epub",
314
- "mobi",
315
- "azw",
316
- "azw3",
317
- "fb2",
318
- "lit",
319
- "lrf",
320
- "cbr",
321
- "cbz",
322
- "cbt",
323
- "cba",
324
- "opds",
325
- // 🔬 Bioinformatics
326
- "fasta",
327
- "fa",
328
- "fas",
329
- "ffn",
330
- "faa",
331
- "fna",
332
- "frn",
333
- "fastq",
334
- "fq",
335
- "gb",
336
- "gbk",
337
- "sam",
338
- "bam",
339
- "vcf",
340
- "gff",
341
- "bed",
342
- // 📝 Etc
343
- "log",
344
- "bak",
345
- "tmp",
346
- "old",
347
- "backup",
348
- "swp",
349
- "part",
350
- "crdownload",
351
- "torrent",
352
- "ics",
353
- "vcf",
354
- "ics",
355
- "ical",
356
- "ics",
357
- "ical",
358
- "calendar",
359
- "srt",
360
- "sub",
361
- "idx",
362
- "cue",
363
- // 🧠 Other broad (technical & scientific extensions)
364
- "cdf",
365
- "hdf",
366
- "h5",
367
- "nc",
368
- "grib",
369
- "fits",
370
- "netcdf",
371
- "sdf",
372
- "vtk",
373
- "xmind",
374
- "drawio",
375
- // ⚙️ Packages & Plugins
376
- "jar",
377
- "war",
378
- "ear",
379
- "crx",
380
- "xpi",
381
- "plugin",
382
- "vsix",
383
- "safariextz"
384
- ]);
385
- var DOUBLE_EXTENSIONS = /* @__PURE__ */ new Set([
386
- "tar.gz",
387
- "tar.bz2",
388
- "tar.xz",
389
- "tar.lz",
390
- "tar.lzma",
391
- "tar.Z",
392
- "tar.zst",
393
- "tar.xz"
394
- ]);
395
- var extractFileName = (url) => {
396
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(url)) return void 0;
397
- let fileName = url.split("/").pop();
398
- if (fileName === "") return "";
399
- if (!fileName) return void 0;
400
- for (const ext of DOUBLE_EXTENSIONS) {
401
- const fullExt = `.${ext}`;
402
- if (fileName.toLowerCase().endsWith(fullExt)) {
403
- return fileName.slice(0, -fullExt.length);
404
- }
405
- }
406
- while (true) {
407
- const lastDot = fileName.lastIndexOf(".");
408
- if (lastDot === -1) break;
409
- const ext = fileName.slice(lastDot + 1).toLowerCase();
410
- if (KNOWN_EXTENSIONS.has(ext)) {
411
- fileName = fileName.slice(0, lastDot);
412
- } else {
413
- break;
414
- }
415
- }
416
- return fileName;
417
- };
418
-
419
- exports.extractFileName = extractFileName;
@@ -1,175 +0,0 @@
1
- /*!
2
- * ====================================================
3
- * Rzl Utils-JS.
4
- * ----------------------------------------------------
5
- * Version: 3.8.0.
6
- * Author: Rizalvin Dwiky.
7
- * Repository: https://github.com/rzl-zone/utils-js.
8
- * ====================================================
9
- */
10
- 'use strict';
11
-
12
- var chunkVJVCXEH7_cjs = require('./chunk-VJVCXEH7.cjs');
13
- var chunkLIU4S3JA_cjs = require('./chunk-LIU4S3JA.cjs');
14
- var chunkNREACG6M_cjs = require('./chunk-NREACG6M.cjs');
15
- var chunkYC7AK3KX_cjs = require('./chunk-YC7AK3KX.cjs');
16
- var chunkF3WBQKRI_cjs = require('./chunk-F3WBQKRI.cjs');
17
-
18
- var NormalizePathnameError = class _NormalizePathnameError extends Error {
19
- /** * ***The original error that triggered this normalization failure.***
20
- *
21
- * **Always available for backward compatibility.**
22
- */
23
- originalError;
24
- constructor(message, originalError) {
25
- super(message, chunkF3WBQKRI_cjs.isFunction(Error) ? { cause: originalError } : void 0);
26
- this.name = "NormalizePathnameError";
27
- this.originalError = originalError;
28
- if (chunkF3WBQKRI_cjs.isFunction(Error.captureStackTrace)) {
29
- Error.captureStackTrace(this, _NormalizePathnameError);
30
- } else {
31
- this.stack = new Error(message).stack;
32
- }
33
- }
34
- /** * ***Safe JSON representation for logging or IPC.*** */
35
- toJSON() {
36
- return {
37
- name: this.name,
38
- message: this.message,
39
- stack: this.stack,
40
- originalError: {
41
- name: this.originalError.name,
42
- message: this.originalError.message,
43
- stack: this.originalError.stack
44
- }
45
- };
46
- }
47
- };
48
-
49
- function normalizePathname(pathname, options = {
50
- defaultPath: "/",
51
- keepNullable: false
52
- }) {
53
- chunkF3WBQKRI_cjs.assertIsPlainObject(options, {
54
- message({ currentType, validType }) {
55
- return `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
56
- }
57
- });
58
- const { defaultPath = "/", keepNullable = false, keepTrailingSlash = false } = options;
59
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(defaultPath)) {
60
- throw new TypeError(
61
- `Parameter \`defaultPath\` property of the \`options\` (second parameter) must be of type \`string\` and not empty-string, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
62
- defaultPath
63
- )}\`, with value: \`${chunkYC7AK3KX_cjs.safeStableStringify(defaultPath, {
64
- keepUndefined: true
65
- })}\`.`
66
- );
67
- }
68
- chunkF3WBQKRI_cjs.assertIsBoolean(keepTrailingSlash, {
69
- message({ currentType, validType }) {
70
- return `Parameter \`keepTrailingSlash\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
71
- }
72
- });
73
- try {
74
- if (keepNullable && (chunkF3WBQKRI_cjs.isNil(pathname) || !chunkF3WBQKRI_cjs.isString(pathname))) {
75
- if (chunkF3WBQKRI_cjs.isNull(pathname)) return null;
76
- return void 0;
77
- }
78
- let currentPathName = chunkF3WBQKRI_cjs.isNonEmptyString(pathname) ? pathname : defaultPath;
79
- currentPathName = chunkLIU4S3JA_cjs.removeSpaces(currentPathName, { trimOnly: true }).replace(
80
- /\s+/g,
81
- ""
82
- );
83
- currentPathName = stripLeadingDomain(currentPathName);
84
- let _pathName = currentPathName;
85
- let search = "";
86
- let hash = "";
87
- const searchIndex = currentPathName.indexOf("?");
88
- const hashIndex = currentPathName.indexOf("#");
89
- if (searchIndex !== -1) {
90
- search = currentPathName.slice(
91
- searchIndex,
92
- hashIndex !== -1 ? hashIndex : void 0
93
- );
94
- }
95
- if (hashIndex !== -1) {
96
- hash = currentPathName.slice(hashIndex);
97
- }
98
- const endIndex = Math.min(
99
- searchIndex !== -1 ? searchIndex : currentPathName.length,
100
- hashIndex !== -1 ? hashIndex : currentPathName.length
101
- );
102
- _pathName = currentPathName.slice(0, endIndex);
103
- _pathName = "/" + _pathName.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
104
- if (!keepTrailingSlash && _pathName !== "/") {
105
- _pathName = _pathName.replace(/\/+$/, "");
106
- }
107
- _pathName = decodeUnicodeSequences(_pathName);
108
- search = decodeUnicodeSequences(search);
109
- hash = decodeUnicodeSequences(hash);
110
- return _pathName + search + hash;
111
- } catch (error) {
112
- const err = chunkF3WBQKRI_cjs.isError(error) ? error : new Error("Unknown error from function `normalizePathname()`.");
113
- throw new NormalizePathnameError(
114
- `Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`,
115
- err
116
- );
117
- }
118
- }
119
- function decodeUnicodeSequences(str) {
120
- return str.replace(/(?:%(?:[0-9A-F]{2})){2,}/gi, (match) => {
121
- try {
122
- const decoded = decodeURIComponent(match);
123
- if (/^[\u0000-\u007F]+$/.test(decoded)) return match;
124
- return decoded;
125
- } catch {
126
- return match;
127
- }
128
- });
129
- }
130
- function stripLeadingDomain(path) {
131
- let currentPath = path;
132
- if (/^https?:\/\//i.test(currentPath)) {
133
- try {
134
- const url = new URL(currentPath);
135
- currentPath = "/" + url.pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/") + url.search + url.hash;
136
- } catch {
137
- }
138
- }
139
- if (currentPath.startsWith("/")) {
140
- currentPath = currentPath.replace(/\/{2,}/g, "/").slice(1);
141
- }
142
- const firstPart = currentPath.split("/")[0];
143
- const domainPart = firstPart.split(":")[0];
144
- if (chunkVJVCXEH7_cjs.isValidDomain(domainPart, {
145
- subdomain: true,
146
- allowUnicode: true,
147
- wildcard: true,
148
- topLevel: false
149
- }) || domainPart === "localhost") {
150
- currentPath = currentPath.slice(firstPart.length);
151
- }
152
- if (!currentPath.startsWith("/")) currentPath = "/" + currentPath;
153
- return currentPath;
154
- }
155
-
156
- var formatEnvPort = (envVar, options = {}) => {
157
- if (!chunkF3WBQKRI_cjs.isNonEmptyString(envVar)) return "";
158
- chunkF3WBQKRI_cjs.assertIsPlainObject(options, {
159
- message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
160
- });
161
- const prefixColon = chunkF3WBQKRI_cjs.hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
162
- if (!chunkF3WBQKRI_cjs.isBoolean(prefixColon)) {
163
- throw new TypeError(
164
- `Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${chunkF3WBQKRI_cjs.getPreciseType(
165
- prefixColon
166
- )}\`.`
167
- );
168
- }
169
- const digitsOnly = envVar.replace(/\D+/g, "");
170
- if (chunkNREACG6M_cjs.isEmptyString(digitsOnly)) return "";
171
- return prefixColon ? `:${digitsOnly}` : digitsOnly;
172
- };
173
-
174
- exports.formatEnvPort = formatEnvPort;
175
- exports.normalizePathname = normalizePathname;