@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.
- package/README.md +5 -1
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +168 -57
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-EK7FSI7F.cjs → chunk-2XGQQZ6A.cjs} +3 -3
- package/dist/{chunk-YS27V6LS.js → chunk-3LE6NX57.js} +5 -176
- package/dist/{chunk-PZQC3FZY.js → chunk-44X74C26.js} +4 -4
- package/dist/{chunk-4ACKNPL5.js → chunk-5KDVIEVO.js} +2 -2
- package/dist/{chunk-JY4HLZ4W.js → chunk-5O66AUEC.js} +2 -2
- package/dist/{chunk-SLP24LUV.js → chunk-5Y6JL47L.js} +3 -3
- package/dist/{chunk-ZW3VYES4.cjs → chunk-62FS7WMB.cjs} +31 -31
- package/dist/{chunk-VJVCXEH7.cjs → chunk-6AMDHVS2.cjs} +9 -181
- package/dist/{chunk-5IKZ3JDV.js → chunk-6WVOUVWD.js} +9 -9
- package/dist/{chunk-BYUT376O.cjs → chunk-76ATVDCR.cjs} +3 -3
- package/dist/{chunk-F3WBQKRI.cjs → chunk-7C7TQC5J.cjs} +29 -7
- package/dist/{chunk-I3IXLEEG.js → chunk-7EIFPHV3.js} +8 -8
- package/dist/{chunk-6RFNZ2ZZ.cjs → chunk-7NXFGJJE.cjs} +14 -14
- package/dist/{chunk-TFDXRT6D.cjs → chunk-ALRISPTL.cjs} +3 -3
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-4ZOXSUXB.js → chunk-C7GC2PFX.js} +3 -3
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-KVZ3HL2B.js → chunk-DXPM4NOU.js} +4 -4
- package/dist/{chunk-DPLL67OT.js → chunk-EJV5AF4L.js} +2 -2
- package/dist/{chunk-NREACG6M.cjs → chunk-FWWPEL7J.cjs} +3 -3
- package/dist/{chunk-LEX4TQW2.js → chunk-GHU356XQ.js} +4 -6
- package/dist/chunk-GKDSBOYE.js +209 -0
- package/dist/{chunk-YC7AK3KX.cjs → chunk-H44QVAZL.cjs} +31 -31
- package/dist/{chunk-AKKM6MOX.cjs → chunk-I33PB44Q.cjs} +15 -15
- package/dist/{chunk-LIU4S3JA.cjs → chunk-IX6PF5ZP.cjs} +4 -4
- package/dist/{chunk-3KTD3QDI.js → chunk-J4TT33ZX.js} +29 -7
- package/dist/{chunk-SZJ7OI4S.js → chunk-J6VLFVIL.js} +3 -3
- package/dist/{chunk-3JD53UUH.cjs → chunk-JI57K7D4.cjs} +161 -161
- package/dist/{chunk-OFBFGFVH.js → chunk-JYOCB6OV.js} +2 -2
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-6NORJBI6.cjs → chunk-KUVRZ2JW.cjs} +50 -50
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-VCVND6CH.js → chunk-M5QB2GM5.js} +2 -2
- package/dist/{chunk-RRJIRXHS.js → chunk-MBFVTGYS.js} +4 -4
- package/dist/{chunk-UKAUXY2U.cjs → chunk-MMRHKYT6.cjs} +12 -12
- package/dist/{chunk-U5VR4TJN.js → chunk-MS2KSKD7.js} +9 -9
- package/dist/{chunk-7ZNEUWYP.js → chunk-MZ3T6L7Z.js} +2 -2
- package/dist/{chunk-ATLFMKAF.cjs → chunk-NAOVH4OH.cjs} +7 -7
- package/dist/{chunk-HKJZ7K2K.cjs → chunk-NJ24M6ZH.cjs} +37 -37
- package/dist/chunk-OCTHWEZK.cjs +249 -0
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-FI76UZRF.js → chunk-OSSFLQDD.js} +3 -4
- package/dist/{chunk-7WBMA2VE.cjs → chunk-OYFUBKEG.cjs} +4 -5
- package/dist/{chunk-B4SDEBN7.cjs → chunk-PWKOFPAH.cjs} +3 -3
- package/dist/{chunk-RJYWBVGD.cjs → chunk-QGTFQ7RO.cjs} +6 -6
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/chunk-QXTJVDWE.js +676 -0
- package/dist/{chunk-B6UIKBHR.cjs → chunk-QZI5PVCI.cjs} +4 -4
- package/dist/{chunk-PW2VMJLT.js → chunk-R2DR7SPJ.js} +99 -25
- package/dist/{chunk-TDYGYHSH.js → chunk-SN5HAK3Y.js} +4 -4
- package/dist/{chunk-P3ST4UZA.js → chunk-SRWL4YCP.js} +7 -7
- package/dist/{chunk-7QQV66RX.cjs → chunk-TJ5OY6MC.cjs} +10 -10
- package/dist/{chunk-6WMB5AJR.js → chunk-TXOVQZPU.js} +3 -4
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-LVFTN6DK.cjs → chunk-UFYMRRJH.cjs} +61 -61
- package/dist/{chunk-5NN4ZDE2.cjs → chunk-UV5BKAYW.cjs} +6 -8
- package/dist/{chunk-GAJBF6DR.js → chunk-UXT4XSUK.js} +2 -2
- package/dist/{chunk-6VA4F6VR.js → chunk-VBSLIIDB.js} +10 -10
- package/dist/chunk-VCYXNIZ2.cjs +678 -0
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-JIROTDOU.js → chunk-WB3FT62A.js} +3 -3
- package/dist/{chunk-K63WO3XA.cjs → chunk-WKM6UVMG.cjs} +4 -5
- package/dist/{chunk-5PF7KRCP.cjs → chunk-WLEZ2KSG.cjs} +126 -126
- package/dist/{chunk-ZN53RM3R.js → chunk-WRGN6UBK.js} +2 -2
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-2VO2CBTU.js → chunk-X6ULJZ3X.js} +2 -2
- package/dist/{chunk-CKUEZF4R.cjs → chunk-XYWC4EQ3.cjs} +71 -71
- package/dist/{chunk-A3YI6Y2P.js → chunk-YHFRCVTN.js} +3 -3
- package/dist/{chunk-A4H7474O.cjs → chunk-YQHJB7KR.cjs} +26 -26
- package/dist/{chunk-YGB2BQPB.cjs → chunk-YVRUY4EW.cjs} +8 -8
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/chunk-ZTHJQJ5F.cjs +211 -0
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +1 -1
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +1 -1
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +9 -9
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/isPlainObject-BTPjv6zB.d.ts +1 -1
- package/dist/next/index.cjs +37 -36
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +9 -8
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -4
- package/dist/parsers/index.d.ts +224 -32
- package/dist/parsers/index.js +5 -3
- package/dist/predicates/index.cjs +77 -76
- package/dist/predicates/index.d.ts +1 -1
- package/dist/predicates/index.js +14 -13
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +2 -3
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +23 -23
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.js +7 -7
- package/dist/tailwind/index.cjs +13 -13
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -21
- package/dist/urls/index.d.ts +182 -114
- package/dist/urls/index.js +16 -14
- package/package.json +1 -1
- package/dist/chunk-KPCDDYTZ.js +0 -417
- package/dist/chunk-QAPYHLHC.cjs +0 -419
- package/dist/chunk-SGCN4ED4.cjs +0 -175
package/dist/urls/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
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
|
-
/**
|
|
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;
|
|
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
|
-
*
|
|
396
|
-
*
|
|
397
|
-
* -
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
* -
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
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
|
|
543
|
+
* // Basic path cleaning
|
|
436
544
|
* normalizePathname(" /foo//bar ");
|
|
437
545
|
* // ➔ "/foo/bar"
|
|
438
546
|
*
|
|
439
|
-
* //
|
|
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
|
-
* //
|
|
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
|
-
* //
|
|
460
|
-
* normalizePathname("
|
|
563
|
+
* // Default fallback
|
|
564
|
+
* normalizePathname("", { defaultPath: "/home" });
|
|
461
565
|
* // ➔ "/home"
|
|
462
566
|
*
|
|
463
|
-
* //
|
|
464
|
-
* normalizePathname(
|
|
465
|
-
* // ➔
|
|
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
|
-
* //
|
|
476
|
-
* normalizePathname("
|
|
477
|
-
* // ➔ "/
|
|
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
|
-
* //
|
|
480
|
-
* normalizePathname("
|
|
481
|
-
* // ➔ "/
|
|
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
|
|
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
|
-
* //
|
|
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
|
-
*
|
|
593
|
+
* normalizePathname("http://");
|
|
502
594
|
* } catch (e) {
|
|
503
|
-
*
|
|
595
|
+
* // console.log(e);
|
|
504
596
|
* }
|
|
505
597
|
*
|
|
506
|
-
* //
|
|
507
|
-
* normalizePathname("/
|
|
508
|
-
* // ➔ "/
|
|
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`.
|
package/dist/urls/index.js
CHANGED
|
@@ -2,24 +2,26 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
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-
|
|
10
|
+
export { constructURL, extractURLs, getFirstPrefixPathname, getPrefixPathname } from '../chunk-6WVOUVWD.js';
|
|
11
11
|
import '../chunk-ONZFBJVW.js';
|
|
12
|
-
import '../chunk-
|
|
13
|
-
import '../chunk-
|
|
14
|
-
import '../chunk-
|
|
15
|
-
import '../chunk-
|
|
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-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import '../chunk-
|
|
21
|
-
import '../chunk-
|
|
22
|
-
import '../chunk-
|
|
23
|
-
import '../chunk-
|
|
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-
|
|
27
|
+
import '../chunk-J4TT33ZX.js';
|