@rzl-zone/utils-js 3.8.0 → 3.9.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.
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
@@ -2,7 +2,7 @@
2
2
  * ====================================================
3
3
  * Rzl Utils-JS.
4
4
  * ----------------------------------------------------
5
- * Version: 3.8.0.
5
+ * Version: 3.9.0.
6
6
  * Author: Rizalvin Dwiky.
7
7
  * Repository: https://github.com/rzl-zone/utils-js.
8
8
  * ====================================================
@@ -383,153 +383,221 @@ defaultPath?:string;
383
383
  * **Must be `true` in this type.**
384
384
  */
385
385
  keepNullable?:true;};type MainNormalizePathnameOptions={
386
- /** * ***Preserve trailing slash at the end of the normalized pathname, defaultValue: `false`.***
386
+ /** --------------------------------------------------------
387
+ * * ***Preserve trailing slash at the end of the normalized pathname, defaultValue: `false`.***
388
+ * --------------------------------------------------------
387
389
  *
388
390
  * @defaultValue `false`
389
391
  */
390
- keepTrailingSlash?:boolean;};type NormalizePathnameOptionsKeepNullableTrue=MainNormalizePathnameOptions & KeepNullableOptions;type NormalizePathnameOptionsKeepNullableFalse=MainNormalizePathnameOptions & UnKeepNullableOptions;type ResUnKeepNullable<T>=T extends undefined?string:T extends null?string:T extends null|undefined?string:string;type ResKeepNullable<T>=T extends string?string:T extends undefined?undefined:T extends null?null:T extends null|undefined?null|undefined:string|null|undefined;
392
+ keepTrailingSlash?:boolean;
393
+ /** --------------------------------------------------------
394
+ * * ***Allow special localhost domain at the beginning of the pathname.***
395
+ * --------------------------------------------------------
396
+ * @description
397
+ * If `true`, the first segment of the pathname that is `/localhost` or `localhost`
398
+ * (with or without a port, e.g., `localhost:3000`) will be treated as a special domain
399
+ * and **removed** from the normalized pathname.
400
+ *
401
+ * - **Examples (`localhostDomain: true`)**:
402
+ * - `"/localhost/path"` ➔ `"/path"`
403
+ * - `"localhost:3000/path"` ➔ `"/path"`
404
+ * - `"localhost"` ➔ `"/"` (entire path removed)
405
+ *
406
+ * - Only the **first path segment** is affected. Any subsequent occurrences of `"localhost"`
407
+ * will remain intact.
408
+ *
409
+ * @defaultValue `false`
410
+ */
411
+ localhostDomain?:boolean;
412
+ /**
413
+ * --------------------------------------------------------
414
+ * * ***Custom list of file extensions that prevent the first path segment from being treated as a domain.***
415
+ * --------------------------------------------------------
416
+ *
417
+ * **Description:**
418
+ * - The first segment of a pathname is often interpreted as a domain (e.g., `example.com`).
419
+ * - If this first segment ends with any of the extensions listed here, it will **not** be considered a domain,
420
+ * and will instead be preserved as part of the relative path.
421
+ * - This is useful for cases where filenames appear at the start of a path and you want them treated as relative paths,
422
+ * such as `"image.png?version=2"` or `"archive.tar.gz#download"`.
423
+ * - Only the **first path segment** is affected; all other segments are processed normally.
424
+ * - **Ignored** if:
425
+ * 1. The pathname starts with a full URL protocol (`http://` or `https://`), e.g., `"https://example.com/file.png"`.
426
+ * 2. The first path segment is already a valid domain, e.g., `"example.com/image.png"`.
427
+ *
428
+ * **Type & Validation:**
429
+ * - Must be a `Set<string>` or `string[]`.
430
+ * - Each string **must include the leading dot**, e.g., `.png`, `.tar.gz`.
431
+ * - Multi-part extensions (like `.tar.gz`, `.tar.bz`) are supported.
432
+ * - Throws a **TypeError** if:
433
+ * 1. The type is not a `Set<string>` or `string[]`.
434
+ * 2. Any string in the array/set is empty.
435
+ * 3. Any string does not start with a dot (`.`).
436
+ *
437
+ * **Usage Notes:**
438
+ * - Only applied when the first segment is otherwise domain-like **and** pathname is relative or domain-like without protocol.
439
+ * - Query strings (`?x=1`) and hash fragments (`#section`) are preserved.
440
+ *
441
+ * **Examples (relative paths, option active):**
442
+ * ```ts
443
+ * normalizePathname("image.png?version=2", {
444
+ * ignoreDomainExtensions: [".png", ".jpg"]
445
+ * });
446
+ * // ➔ "/image.png?version=2"
447
+ *
448
+ * normalizePathname("archive.tar.gz#download", {
449
+ * ignoreDomainExtensions: new Set([".tar.gz"])
450
+ * });
451
+ * // ➔ "/archive.tar.gz#download"
452
+ *
453
+ * normalizePathname("script.js?module=true#top", {
454
+ * ignoreDomainExtensions: [".js"]
455
+ * });
456
+ * // ➔ "/script.js?module=true#top"
457
+ * ```
458
+ *
459
+ * **Examples (full URL or explicit domain - option ignored):**
460
+ * ```ts
461
+ * normalizePathname("https://example.com/image.png?version=2", {
462
+ * ignoreDomainExtensions: [".png"]
463
+ * });
464
+ * // ➔ "/image.png?version=2" // URL is parsed normally; ignoreDomainExtensions has no effect
465
+ *
466
+ * normalizePathname("example.com/script.js?module=true#top", {
467
+ * ignoreDomainExtensions: [".js"]
468
+ * });
469
+ * // ➔ "/script.js?module=true#top" // domain recognized; option ignored
470
+ * ```
471
+ *
472
+ * **Notes:**
473
+ * - Only the **first path segment** is checked.
474
+ * - Prevents false-positive domain stripping for filenames that look like domains.
475
+ * - Throws **TypeError** if invalid type or invalid string is provided.
476
+ *
477
+ * @defaultValue `undefined` (feature inactive if not provided)
478
+ */
479
+ ignoreDomainExtensions?:Set<string>|string[];};type NormalizePathnameOptionsKeepNullableTrue=MainNormalizePathnameOptions & KeepNullableOptions;type NormalizePathnameOptionsKeepNullableFalse=MainNormalizePathnameOptions & UnKeepNullableOptions;type ResUnKeepNullable<T>=T extends undefined?string:T extends null?string:T extends null|undefined?string:string;type ResKeepNullable<T>=T extends string?string:T extends undefined?undefined:T extends null?null:T extends null|undefined?null|undefined:string|null|undefined;
391
480
  /** --------------------------------------------------------
392
481
  * * ***Utility: `normalizePathname`.***
393
482
  * --------------------------------------------------------
483
+ *
394
484
  * - **Description:**
395
- * - Normalizes a given pathname string for consistent routing, URL handling, and string hygiene.
396
- * - It trims whitespace, collapses redundant slashes, handles full URLs, query strings, hash fragments,
397
- * - Unicode characters, emojis, and optionally preserves `null` or `undefined`.
398
- * - Trailing slash behavior can be controlled via `keepTrailingSlash`.
399
- *
400
- * - **Behavior Details:**
401
- * - Trims leading and trailing whitespace.
402
- * - Removes all internal spaces.
403
- * - Collapses multiple consecutive slashes into a single `/`.
404
- * - Prepends a leading slash if missing.
405
- * - Preserves trailing slash only if `keepTrailingSlash` is `true`.
406
- * - Supports full URLs (`http://` or `https://`) and relative paths only also detect valid domain and
407
- * subdomain (with support handle wildcard eg: *.example.com) (with optional with port) eg (localhost, localhost:3000, example.com, sub.domain.com, *.domain.test, etc).
408
- * - Preserves query strings (`?key=value`) and hash fragments (`#anchor`) intact.
409
- * - Handles emojis and Unicode safely.
410
- * - Returns `string`, `null` or `undefined` as-is if `keepNullable` is true.
411
- * - Returns `undefined` if pathname is not a string and `keepNullable` is `true`.
412
- * - Returns `defaultPath` if pathname is empty-string even when `keepNullable` is true.
413
- * - Returns `defaultPath` if pathname is empty/invalid and `keepNullable` is `false`.
414
- *
415
- * - **Options (`options`)**:
416
- * - `defaultPath` (***`string`***, default: **`"/"`**)
417
- * - Fallback path if the input is invalid (**empty-string**, **null**, **undefined**) and
418
- * `keepNullable` is **false**, if `keepNullable` is true, used only when pathname is empty-string.
419
- * - `keepNullable` (***`boolean`***, default: **`false`**)
420
- * - If **true**, preserves `null` or `undefined` as-is instead of returning
421
- * `defaultPath` (except if `pathname` is **empty-string**).
422
- * - `keepTrailingSlash` (***`boolean`***, default: **`false`**)
423
- * - If **true**, preserves a trailing slash at the end of the normalized pathname.
424
- *
425
- * @param {string | null | undefined} pathname - ***The pathname to normalize.***
426
- * @param {NormalizePathnameOptions} [options] - ***Configuration options.***
427
- *
428
- * @returns {string | null | undefined} ***Normalized pathname, or original nullable value if `keepNullable` is `true`
429
- * _(except if `pathname` is empty-string, will keep returning `defaultPath`)_.***
430
- *
431
- * @throws **{@link TypeError | `TypeError`}** if `defaultPath` is invalid when `keepNullable` is false.
432
- * @throws **`NormalizePathnameError` extends {@link Error | `Error`}** If normalization fails (e.g., invalid URL).
485
+ * Normalizes any pathname or URL string to a clean, predictable format.
486
+ * Useful for routing, file paths, and URL handling.
487
+ * - Handles:
488
+ * - Leading/trailing spaces
489
+ * - Internal spaces in path segments
490
+ * - Redundant slashes (`//`)
491
+ * - Full URLs vs relative paths
492
+ * - Query (`?`) and hash (`#`) preservation
493
+ * - Unicode & emoji characters
494
+ * - Optional nullable preservation (`keepNullable`)
495
+ * - Optional trailing slash preservation (`keepTrailingSlash`)
496
+ * - Optional removal of localhost first segment (`localhostDomain`)
497
+ * - Prevention of false-positive domain stripping (`ignoreDomainExtensions`)
498
+ *
499
+ * - **Key Steps Internally:**
500
+ * 1. Validate `options` (plain object, correct types)
501
+ * 2. Validate `defaultPath` (non-empty string if `keepNullable` is false)
502
+ * 3. Validate `ignoreDomainExtensions` (Set<string> | string[], each starts with `.`)
503
+ * 4. Handle nullable:
504
+ * - Returns `null` / `undefined` if `keepNullable: true`
505
+ * - Otherwise uses `defaultPath`
506
+ * 5. Trim spaces, remove internal spaces
507
+ * 6. If full URL: parse using `URL` constructor
508
+ * 7. If relative path or domain-like:
509
+ * - Remove `localhost`/`localhost:port` if `localhostDomain`
510
+ * - Remove first segment if domain-like and **not** in `ignoreDomainExtensions`
511
+ * 8. Normalize slashes
512
+ * 9. Ensure leading slash
513
+ * 10. Handle trailing slash
514
+ * 11. Decode Unicode safely
515
+ * 12. Return normalized pathname + search + hash
516
+ *
517
+ * - **Error Handling:**
518
+ * - **TypeError**:
519
+ * - `defaultPath` invalid (non-string or empty) when `keepNullable: false`
520
+ * - `keepNullable`, `keepTrailingSlash`, `localhostDomain` not boolean
521
+ * - `ignoreDomainExtensions` invalid
522
+ * - **NormalizePathnameError** (extends ***Error***):
523
+ * - Invalid URL parsing
524
+ * - Unexpected normalization errors
525
+ *
526
+ * - **Options:**
527
+ * ```ts
528
+ * {
529
+ * // fallback if invalid path, default: "/"
530
+ * defaultPath?: string;
531
+ * // preserve null/undefined, default: false
532
+ * keepNullable?: boolean;
533
+ * // preserve trailing slash, default: false
534
+ * keepTrailingSlash?: boolean;
535
+ * // remove localhost:port first segment, default: false
536
+ * localhostDomain?: boolean;
537
+ * // prevent domain stripping, default: undefined
538
+ * ignoreDomainExtensions?: Set<string> | string[];
539
+ * }
540
+ * ```
433
541
  *
434
542
  * @example
435
- * // Basic normalization
543
+ * // Basic path cleaning
436
544
  * normalizePathname(" /foo//bar ");
437
545
  * // ➔ "/foo/bar"
438
546
  *
439
- * // Full URL with query and hash
547
+ * // Trailing slash control
548
+ * normalizePathname("/api//v1//user//", { keepTrailingSlash: true });
549
+ * // ➔ "/api/v1/user/"
550
+ * normalizePathname("/api//v1//user//", { keepTrailingSlash: false });
551
+ * // ➔ "/api/v1/user"
552
+ *
553
+ * // Full URL normalization
440
554
  * normalizePathname("https://example.com//path///to/resource?x=1#hash");
441
555
  * // ➔ "/path/to/resource?x=1#hash"
442
556
  *
443
- * // Empty string returns defaultPath
444
- * normalizePathname(" ");
445
- * // ➔ "/"
446
- *
447
- * // Return defaultPath if isn't valid pathname and keepNullable is `undefined` or `false`.
448
- * normalizePathname(null, { defaultPath: "/home" });
449
- * // ➔ "/home"
450
- *
451
- * // Preserve null
557
+ * // Null/undefined preservation
452
558
  * normalizePathname(null, { keepNullable: true });
453
559
  * // ➔ null
454
- *
455
- * // Preserve undefined
456
560
  * normalizePathname(undefined, { keepNullable: true });
457
561
  * // ➔ undefined
458
562
  *
459
- * // Return defaultPath if pathname is empty-string even with keepNullable
460
- * normalizePathname(" ", { keepNullable: true, defaultPath:"/home" });
563
+ * // Default fallback
564
+ * normalizePathname("", { defaultPath: "/home" });
461
565
  * // ➔ "/home"
462
566
  *
463
- * // Return undefined if pathname is not a valid-string.
464
- * normalizePathname(true, { keepNullable: true, defaultPath:"/home" });
465
- * // ➔ undefined
466
- *
467
- * // Collapse multiple slashes
468
- * normalizePathname("/double//slashes");
469
- * // ➔ "/double/slashes"
470
- *
471
- * // Handles emoji and Unicode
472
- * normalizePathname(" nested / path / 🚀 ");
473
- * // ➔ "/nested/path/🚀"
567
+ * // Localhost removal
568
+ * normalizePathname("localhost:3000/path/to/resource", { localhostDomain: true });
569
+ * // ➔ "/path/to/resource"
474
570
  *
475
- * // Query and hash preserved
476
- * normalizePathname("/dashboard///stats?view=all#top");
477
- * // ➔ "/dashboard/stats?view=all#top"
571
+ * // Prevent false-positive domain stripping
572
+ * normalizePathname("archive.tar.gz#download", { ignoreDomainExtensions: [".tar.gz"] });
573
+ * // ➔ "/archive.tar.gz#download"
574
+ * normalizePathname("image.png?version=2", { ignoreDomainExtensions: [".png"] });
575
+ * // ➔ "/image.png?version=2"
478
576
  *
479
- * // Leading/trailing slashes normalized
480
- * normalizePathname("///api//v1///user/");
481
- * // ➔ "/api/v1/user"
482
- *
483
- * // Keep trailing slash if option enabled
484
- * normalizePathname("///api//v1///user//", { keepTrailingSlash: true });
485
- * // ➔ "/api/v1/user/"
486
- *
487
- * // Relative-like paths handled safely
488
- * normalizePathname("path/to/page");
489
- * // ➔ "/path/to/page"
577
+ * // Emojis and Unicode
578
+ * normalizePathname("🔥//deep//path///🚀");
579
+ * // ➔ "/🔥/deep/path/🚀"
490
580
  *
491
- * // Query-only path
581
+ * // Query-only or hash-only
492
582
  * normalizePathname("?page=2");
493
583
  * // ➔ "/?page=2"
494
- *
495
- * // Hash-only path
496
584
  * normalizePathname("#section3");
497
585
  * // ➔ "/#section3"
498
586
  *
499
- * // URL parsing failure triggers custom error
587
+ * // Complex nested paths
588
+ * normalizePathname(" //nested///folder//file.txt ");
589
+ * // ➔ "/nested/folder/file.txt"
590
+ *
591
+ * // Invalid URL triggers error
500
592
  * try {
501
- * normalizePathname("http://");
593
+ * normalizePathname("http://");
502
594
  * } catch (e) {
503
- * // console.log(e);
595
+ * // console.log(e);
504
596
  * }
505
597
  *
506
- * // Internal encoded spaces preserved
507
- * normalizePathname("/search/%20item%20");
508
- * // ➔ "/search/%20item%20"
509
- *
510
- * // Edge case: relative URL-like input
511
- * normalizePathname("localhost/path");
512
- * // ➔ "/path"
513
- * normalizePathname("localhost:3000/path");
514
- * // ➔ "/path"
515
- * normalizePathname("example.com/path");
516
- * // ➔ "/path"
517
- * normalizePathname("sub.domain.com/path");
518
- * // ➔ "/path"
519
- * normalizePathname("*.domain.com/path");
520
- * // ➔ "/path"
521
- *
522
- * // Deeply nested messy path
523
- * normalizePathname(" /🔥//deep//path///🚀 ");
524
- * // ➔ "/🔥/deep/path/🚀"
525
- *
526
- * // Edge case: root slash
527
- * normalizePathname("/");
528
- * // ➔ "/"
529
- *
530
- * // Edge case: multiple spaces only
531
- * normalizePathname(" ");
532
- * // ➔ "/"
598
+ * // First segment is domain but ignored due to extension
599
+ * normalizePathname("example.tar.bz/file", { ignoreDomainExtensions: [".tar.bz"] });
600
+ * // ➔ "/example.tar.bz/file"
533
601
  */
534
602
  declare function normalizePathname<T>(pathname:T,options?:NormalizePathnameOptionsKeepNullableFalse):ResUnKeepNullable<T>;declare function normalizePathname<T>(pathname:T,options?:NormalizePathnameOptionsKeepNullableTrue):ResKeepNullable<T>;type FormatEnvPortOptions={
535
603
  /** Add prefix with a colon, defaultValue: `false`.
@@ -2,24 +2,26 @@
2
2
  * ====================================================
3
3
  * Rzl Utils-JS.
4
4
  * ----------------------------------------------------
5
- * Version: 3.8.0.
5
+ * Version: 3.9.0.
6
6
  * Author: Rizalvin Dwiky.
7
7
  * Repository: https://github.com/rzl-zone/utils-js.
8
8
  * ====================================================
9
9
  */
10
- export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname } from '../chunk-5IKZ3JDV.js';
10
+ export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname } from '../chunk-6WVOUVWD.js';
11
11
  import '../chunk-ONZFBJVW.js';
12
- import '../chunk-GAJBF6DR.js';
13
- import '../chunk-TDYGYHSH.js';
14
- import '../chunk-PZQC3FZY.js';
15
- import '../chunk-7ZNEUWYP.js';
12
+ import '../chunk-UXT4XSUK.js';
13
+ import '../chunk-SN5HAK3Y.js';
14
+ import '../chunk-44X74C26.js';
15
+ import '../chunk-MZ3T6L7Z.js';
16
16
  import '../chunk-WVSPXFTY.js';
17
- export { formatEnvPort, normalizePathname } from '../chunk-PW2VMJLT.js';
18
- export { punycodeUtilsJS } from '../chunk-YS27V6LS.js';
19
- import '../chunk-4ACKNPL5.js';
20
- import '../chunk-JY4HLZ4W.js';
21
- import '../chunk-VCVND6CH.js';
22
- import '../chunk-6WMB5AJR.js';
23
- import '../chunk-2VO2CBTU.js';
17
+ export { formatEnvPort, normalizePathname } from '../chunk-R2DR7SPJ.js';
18
+ import '../chunk-3LE6NX57.js';
19
+ export { punycodeUtilsJS } from '../chunk-GKDSBOYE.js';
20
+ import '../chunk-5KDVIEVO.js';
21
+ import '../chunk-5O66AUEC.js';
22
+ import '../chunk-OSSFLQDD.js';
23
+ import '../chunk-M5QB2GM5.js';
24
+ import '../chunk-TXOVQZPU.js';
25
+ import '../chunk-X6ULJZ3X.js';
24
26
  import '../chunk-QNKGP5DY.js';
25
- import '../chunk-3KTD3QDI.js';
27
+ import '../chunk-J4TT33ZX.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rzl-zone/utils-js",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "sideEffects": false,
5
5
  "engineStrict": true,
6
6
  "license": "MIT",