@rzl-zone/utils-js 3.5.7 → 3.6.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 +1 -1
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +1 -1
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-2CQI36UD.cjs +1 -1
- package/dist/chunk-2VO2CBTU.js +1 -1
- package/dist/chunk-3KTD3QDI.js +1 -1
- package/dist/chunk-4ACKNPL5.js +1 -1
- package/dist/chunk-4ZOXSUXB.js +1 -1
- package/dist/chunk-5NN4ZDE2.cjs +1 -1
- package/dist/chunk-66WLOZOD.cjs +1 -1
- package/dist/{chunk-6DSPJA5U.js → chunk-6PKW4WCT.js} +2 -2
- package/dist/chunk-6RFNZ2ZZ.cjs +1 -1
- package/dist/chunk-6WMB5AJR.js +1 -1
- package/dist/chunk-7QQV66RX.cjs +1 -1
- package/dist/chunk-7WBMA2VE.cjs +1 -1
- package/dist/chunk-7ZNEUWYP.js +1 -1
- package/dist/chunk-A3YI6Y2P.js +1 -1
- package/dist/chunk-ABA2ZSBQ.js +1 -1
- package/dist/chunk-AKKM6MOX.cjs +1 -1
- package/dist/chunk-ATLFMKAF.cjs +1 -1
- package/dist/chunk-B4SDEBN7.cjs +1 -1
- package/dist/chunk-B6UIKBHR.cjs +1 -1
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/chunk-BG3AS5BU.cjs +173 -0
- package/dist/chunk-BYUT376O.cjs +1 -1
- package/dist/{chunk-RIEYB2AW.cjs → chunk-CKUEZF4R.cjs} +1 -1
- package/dist/chunk-D53CE4BT.js +1 -1
- package/dist/chunk-DPLL67OT.js +1 -1
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/chunk-EK7FSI7F.cjs +1 -1
- package/dist/chunk-F3WBQKRI.cjs +1 -1
- package/dist/chunk-FI76UZRF.js +1 -1
- package/dist/chunk-GAJBF6DR.js +1 -1
- package/dist/chunk-JY4HLZ4W.js +1 -1
- package/dist/chunk-K3SONK25.cjs +1 -1
- package/dist/chunk-K63WO3XA.cjs +1 -1
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/chunk-KPCDDYTZ.js +1 -1
- package/dist/chunk-KTQLDIIT.cjs +1 -1
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/chunk-LEX4TQW2.js +1 -1
- package/dist/chunk-LIU4S3JA.cjs +1 -1
- package/dist/chunk-NREACG6M.cjs +1 -1
- package/dist/chunk-OFBFGFVH.js +1 -1
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/chunk-OS5OT5JA.cjs +1 -1
- package/dist/chunk-PZQC3FZY.js +1 -1
- package/dist/chunk-QAPYHLHC.cjs +1 -1
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/chunk-QUITZ3GP.js +1 -1
- package/dist/{chunk-H5NWBTHW.cjs → chunk-R3PBF6F7.cjs} +11 -11
- package/dist/chunk-RMJC3B5P.cjs +1 -1
- package/dist/chunk-RS5RBLPB.js +1 -1
- package/dist/chunk-SZJ7OI4S.js +1 -1
- package/dist/chunk-TDPYR5JY.js +1 -1
- package/dist/chunk-TDYGYHSH.js +1 -1
- package/dist/chunk-TFDXRT6D.cjs +1 -1
- package/dist/chunk-TPYENEQ4.cjs +1 -1
- package/dist/{chunk-SN6YRDLG.js → chunk-U5VR4TJN.js} +1 -1
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/chunk-UKAUXY2U.cjs +1 -1
- package/dist/chunk-VCVND6CH.js +1 -1
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/chunk-VJVCXEH7.cjs +1997 -0
- package/dist/chunk-VNADVWSJ.js +1 -1
- package/dist/chunk-WNO3EPYT.js +170 -0
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/chunk-XFTUHS4Y.js +1 -1
- package/dist/chunk-YC7AK3KX.cjs +1 -1
- package/dist/chunk-YGB2BQPB.cjs +1 -1
- package/dist/chunk-YS27V6LS.js +1994 -0
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/chunk-ZN53RM3R.js +1 -1
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +1 -1
- package/dist/conversions/index.js +1 -1
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +1 -1
- package/dist/formatters/index.cjs +1 -1
- package/dist/formatters/index.d.ts +1 -1
- package/dist/formatters/index.js +1 -1
- package/dist/generators/index.cjs +1 -1
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/isPlainObject-FWmcJF6k.d.ts +1 -1
- package/dist/next/index.cjs +9 -8
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +3 -2
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +1 -1
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +1 -1
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +1 -1
- package/dist/predicates/index.cjs +33 -28
- package/dist/predicates/index.d.ts +142 -2
- package/dist/predicates/index.js +3 -2
- package/dist/promises/index.cjs +1 -1
- package/dist/promises/index.d.ts +1 -1
- package/dist/promises/index.js +1 -1
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/tailwind/index.cjs +1 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +1 -1
- package/dist/urls/index.cjs +14 -9
- package/dist/urls/index.d.ts +268 -19
- package/dist/urls/index.js +4 -3
- package/package.json +11 -2
- package/dist/chunk-LBNOZIZ6.js +0 -90
- package/dist/chunk-URDI3IMY.cjs +0 -93
package/dist/strings/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/strings/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/strings/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/tailwind/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/tailwind/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/tailwind/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
package/dist/urls/index.cjs
CHANGED
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var chunkR3PBF6F7_cjs = require('../chunk-R3PBF6F7.cjs');
|
|
13
13
|
require('../chunk-KHO2SBNA.cjs');
|
|
14
14
|
require('../chunk-BYUT376O.cjs');
|
|
15
15
|
require('../chunk-AKKM6MOX.cjs');
|
|
16
16
|
require('../chunk-UKAUXY2U.cjs');
|
|
17
17
|
require('../chunk-B4SDEBN7.cjs');
|
|
18
18
|
require('../chunk-DVMHRLKP.cjs');
|
|
19
|
-
var
|
|
19
|
+
var chunkBG3AS5BU_cjs = require('../chunk-BG3AS5BU.cjs');
|
|
20
|
+
var chunkVJVCXEH7_cjs = require('../chunk-VJVCXEH7.cjs');
|
|
20
21
|
require('../chunk-LIU4S3JA.cjs');
|
|
21
22
|
require('../chunk-NREACG6M.cjs');
|
|
22
23
|
require('../chunk-ATLFMKAF.cjs');
|
|
@@ -27,25 +28,29 @@ require('../chunk-F3WBQKRI.cjs');
|
|
|
27
28
|
|
|
28
29
|
Object.defineProperty(exports, "constructURL", {
|
|
29
30
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkR3PBF6F7_cjs.constructURL; }
|
|
31
32
|
});
|
|
32
33
|
Object.defineProperty(exports, "extractURLs", {
|
|
33
34
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkR3PBF6F7_cjs.extractURLs; }
|
|
35
36
|
});
|
|
36
37
|
Object.defineProperty(exports, "getFirstPrefixPathname", {
|
|
37
38
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkR3PBF6F7_cjs.getFirstPrefixPathname; }
|
|
39
40
|
});
|
|
40
41
|
Object.defineProperty(exports, "getPrefixPathname", {
|
|
41
42
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunkR3PBF6F7_cjs.getPrefixPathname; }
|
|
43
44
|
});
|
|
44
45
|
Object.defineProperty(exports, "formatEnvPort", {
|
|
45
46
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkBG3AS5BU_cjs.formatEnvPort; }
|
|
47
48
|
});
|
|
48
49
|
Object.defineProperty(exports, "normalizePathname", {
|
|
49
50
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunkBG3AS5BU_cjs.normalizePathname; }
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, "punycodeUtilsJS", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return chunkVJVCXEH7_cjs.punycodeUtilsJS; }
|
|
51
56
|
});
|
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.6.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -347,39 +347,192 @@ removeDuplicates?:boolean;};
|
|
|
347
347
|
* ```
|
|
348
348
|
*/
|
|
349
349
|
declare const getPrefixPathname:(url:string|string[],base?:string|string[]|null,options?:GetPrefixPathnameOptions)=>string|string[]|null;
|
|
350
|
+
/** Options when `keepNullable` is false (default).
|
|
351
|
+
*
|
|
352
|
+
* Returns `defaultPath` if `pathname` is empty or invalid.
|
|
353
|
+
*/
|
|
354
|
+
type UnKeepNullableOptions={
|
|
355
|
+
/** * ***Fallback value returned if `pathname` is empty-string or invalid.***
|
|
356
|
+
*
|
|
357
|
+
* Must be a **`non-empty string`**, defaultValue: `"/"`.
|
|
358
|
+
*
|
|
359
|
+
* @defaultValue `"/"`.
|
|
360
|
+
*/
|
|
361
|
+
defaultPath?:string;
|
|
362
|
+
/** * ***Whether to preserve `null` or `undefined`, defaultValue: `false`.***
|
|
363
|
+
*
|
|
364
|
+
* @defaultValue `false`.
|
|
365
|
+
*/
|
|
366
|
+
keepNullable?:false;};
|
|
367
|
+
/** Options when `keepNullable` is true.
|
|
368
|
+
*
|
|
369
|
+
* Preserves `null` or `undefined` instead of returning `defaultPath`.
|
|
370
|
+
*/
|
|
371
|
+
type KeepNullableOptions={
|
|
372
|
+
/** * ***Fallback path is ignored when `keepNullable` is true **(except if
|
|
373
|
+
* `pathname` is empty-string or invalid, even this `true`)**,
|
|
374
|
+
* defaultValue: `"/"`.***
|
|
375
|
+
*
|
|
376
|
+
* @defaultValue `"/"`.
|
|
377
|
+
*/
|
|
378
|
+
defaultPath?:string;
|
|
379
|
+
/** * ***Preserve `null` or `undefined` as-is if `true` (defaultValue: `false`).***
|
|
380
|
+
*
|
|
381
|
+
* - ***⚠️ Notes:***
|
|
382
|
+
* - Keep returning `defaultPath` if `pathname` is empty-string, even this `true`.
|
|
383
|
+
*
|
|
384
|
+
* **Must be `true` in this type.**
|
|
385
|
+
*/
|
|
386
|
+
keepNullable?:true;};type MainNormalizePathnameOptions={
|
|
387
|
+
/** * ***Preserve trailing slash at the end of the normalized pathname, defaultValue: `false`.***
|
|
388
|
+
*
|
|
389
|
+
* @defaultValue `false`
|
|
390
|
+
*/
|
|
391
|
+
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;
|
|
350
392
|
/** --------------------------------------------------------
|
|
351
393
|
* * ***Utility: `normalizePathname`.***
|
|
352
394
|
* --------------------------------------------------------
|
|
353
|
-
* **
|
|
354
|
-
*
|
|
355
|
-
* -
|
|
356
|
-
* -
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* -
|
|
361
|
-
* -
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
395
|
+
* - **Description:**
|
|
396
|
+
* - Normalizes a given pathname string for consistent routing, URL handling, and string hygiene.
|
|
397
|
+
* - It trims whitespace, collapses redundant slashes, handles full URLs, query strings, hash fragments,
|
|
398
|
+
* - Unicode characters, emojis, and optionally preserves `null` or `undefined`.
|
|
399
|
+
* - Trailing slash behavior can be controlled via `keepTrailingSlash`.
|
|
400
|
+
*
|
|
401
|
+
* - **Behavior Details:**
|
|
402
|
+
* - Trims leading and trailing whitespace.
|
|
403
|
+
* - Removes all internal spaces.
|
|
404
|
+
* - Collapses multiple consecutive slashes into a single `/`.
|
|
405
|
+
* - Prepends a leading slash if missing.
|
|
406
|
+
* - Preserves trailing slash only if `keepTrailingSlash` is `true`.
|
|
407
|
+
* - Supports full URLs (`http://` or `https://`) and relative paths only also detect valid domain and
|
|
408
|
+
* subdomain (with support handle wildcard eg: *.example.com) (with optional with port) eg (localhost, localhost:3000, example.com, sub.domain.com, *.domain.test, etc).
|
|
409
|
+
* - Preserves query strings (`?key=value`) and hash fragments (`#anchor`) intact.
|
|
410
|
+
* - Handles emojis and Unicode safely.
|
|
411
|
+
* - Returns `string`, `null` or `undefined` as-is if `keepNullable` is true.
|
|
412
|
+
* - Returns `undefined` if pathname is not a string and `keepNullable` is `true`.
|
|
413
|
+
* - Returns `defaultPath` if pathname is empty-string even when `keepNullable` is true.
|
|
414
|
+
* - Returns `defaultPath` if pathname is empty/invalid and `keepNullable` is `false`.
|
|
415
|
+
*
|
|
416
|
+
* - **Options (`options`)**:
|
|
417
|
+
* - `defaultPath` (***`string`***, default: **`"/"`**)
|
|
418
|
+
* - Fallback path if the input is invalid (**empty-string**, **null**, **undefined**) and
|
|
419
|
+
* `keepNullable` is **false**, if `keepNullable` is true, used only when pathname is empty-string.
|
|
420
|
+
* - `keepNullable` (***`boolean`***, default: **`false`**)
|
|
421
|
+
* - If **true**, preserves `null` or `undefined` as-is instead of returning
|
|
422
|
+
* `defaultPath` (except if `pathname` is **empty-string**).
|
|
423
|
+
* - `keepTrailingSlash` (***`boolean`***, default: **`false`**)
|
|
424
|
+
* - If **true**, preserves a trailing slash at the end of the normalized pathname.
|
|
425
|
+
*
|
|
426
|
+
* @param {string | null | undefined} pathname - ***The pathname to normalize.***
|
|
427
|
+
* @param {NormalizePathnameOptions} [options] - ***Configuration options.***
|
|
428
|
+
*
|
|
429
|
+
* @returns {string | null | undefined} ***Normalized pathname, or original nullable value if `keepNullable` is `true`
|
|
430
|
+
* _(except if `pathname` is empty-string, will keep returning `defaultPath`)_.***
|
|
431
|
+
*
|
|
432
|
+
* @throws {TypeError} If `defaultPath` is invalid when `keepNullable` is false.
|
|
433
|
+
* @throws {NormalizePathnameError} If normalization fails (e.g., invalid URL).
|
|
434
|
+
*
|
|
368
435
|
* @example
|
|
436
|
+
* // Basic normalization
|
|
369
437
|
* normalizePathname(" /foo//bar ");
|
|
370
438
|
* // ➔ "/foo/bar"
|
|
439
|
+
*
|
|
440
|
+
* // Full URL with query and hash
|
|
371
441
|
* normalizePathname("https://example.com//path///to/resource?x=1#hash");
|
|
372
442
|
* // ➔ "/path/to/resource?x=1#hash"
|
|
443
|
+
*
|
|
444
|
+
* // Empty string returns defaultPath
|
|
373
445
|
* normalizePathname(" ");
|
|
374
446
|
* // ➔ "/"
|
|
375
|
-
*
|
|
447
|
+
*
|
|
448
|
+
* // Return defaultPath if isn't valid pathname and keepNullable is `undefined` or `false`.
|
|
449
|
+
* normalizePathname(null, { defaultPath: "/home" });
|
|
450
|
+
* // ➔ "/home"
|
|
451
|
+
*
|
|
452
|
+
* // Preserve null
|
|
453
|
+
* normalizePathname(null, { keepNullable: true });
|
|
454
|
+
* // ➔ null
|
|
455
|
+
*
|
|
456
|
+
* // Preserve undefined
|
|
457
|
+
* normalizePathname(undefined, { keepNullable: true });
|
|
458
|
+
* // ➔ undefined
|
|
459
|
+
*
|
|
460
|
+
* // Return defaultPath if pathname is empty-string even with keepNullable
|
|
461
|
+
* normalizePathname(" ", { keepNullable: true, defaultPath:"/home" });
|
|
376
462
|
* // ➔ "/home"
|
|
463
|
+
*
|
|
464
|
+
* // Return undefined if pathname is not a valid-string.
|
|
465
|
+
* normalizePathname(true, { keepNullable: true, defaultPath:"/home" });
|
|
466
|
+
* // ➔ undefined
|
|
467
|
+
*
|
|
468
|
+
* // Collapse multiple slashes
|
|
377
469
|
* normalizePathname("/double//slashes");
|
|
378
470
|
* // ➔ "/double/slashes"
|
|
471
|
+
*
|
|
472
|
+
* // Handles emoji and Unicode
|
|
379
473
|
* normalizePathname(" nested / path / 🚀 ");
|
|
380
474
|
* // ➔ "/nested/path/🚀"
|
|
475
|
+
*
|
|
476
|
+
* // Query and hash preserved
|
|
477
|
+
* normalizePathname("/dashboard///stats?view=all#top");
|
|
478
|
+
* // ➔ "/dashboard/stats?view=all#top"
|
|
479
|
+
*
|
|
480
|
+
* // Leading/trailing slashes normalized
|
|
481
|
+
* normalizePathname("///api//v1///user/");
|
|
482
|
+
* // ➔ "/api/v1/user"
|
|
483
|
+
*
|
|
484
|
+
* // Keep trailing slash if option enabled
|
|
485
|
+
* normalizePathname("///api//v1///user//", { keepTrailingSlash: true });
|
|
486
|
+
* // ➔ "/api/v1/user/"
|
|
487
|
+
*
|
|
488
|
+
* // Relative-like paths handled safely
|
|
489
|
+
* normalizePathname("path/to/page");
|
|
490
|
+
* // ➔ "/path/to/page"
|
|
491
|
+
*
|
|
492
|
+
* // Query-only path
|
|
493
|
+
* normalizePathname("?page=2");
|
|
494
|
+
* // ➔ "/?page=2"
|
|
495
|
+
*
|
|
496
|
+
* // Hash-only path
|
|
497
|
+
* normalizePathname("#section3");
|
|
498
|
+
* // ➔ "/#section3"
|
|
499
|
+
*
|
|
500
|
+
* // URL parsing failure triggers custom error
|
|
501
|
+
* try {
|
|
502
|
+
* normalizePathname("http://");
|
|
503
|
+
* } catch (e) {
|
|
504
|
+
* // ➔ console.log(e);
|
|
505
|
+
* }
|
|
506
|
+
*
|
|
507
|
+
* // Internal encoded spaces preserved
|
|
508
|
+
* normalizePathname("/search/%20item%20");
|
|
509
|
+
* // ➔ "/search/%20item%20"
|
|
510
|
+
*
|
|
511
|
+
* // Edge case: relative URL-like input
|
|
512
|
+
* normalizePathname("localhost/path");
|
|
513
|
+
* // ➔ "/path"
|
|
514
|
+
* normalizePathname("localhost:3000/path");
|
|
515
|
+
* // ➔ "/path"
|
|
516
|
+
* normalizePathname("example.com/path");
|
|
517
|
+
* // ➔ "/path"
|
|
518
|
+
* normalizePathname("sub.domain.com/path");
|
|
519
|
+
* // ➔ "/path"
|
|
520
|
+
* normalizePathname("*.domain.com/path");
|
|
521
|
+
* // ➔ "/path"
|
|
522
|
+
*
|
|
523
|
+
* // Deeply nested messy path
|
|
524
|
+
* normalizePathname(" /🔥//deep//path///🚀 ");
|
|
525
|
+
* // ➔ "/🔥/deep/path/🚀"
|
|
526
|
+
*
|
|
527
|
+
* // Edge case: root slash
|
|
528
|
+
* normalizePathname("/");
|
|
529
|
+
* // ➔ "/"
|
|
530
|
+
*
|
|
531
|
+
* // Edge case: multiple spaces only
|
|
532
|
+
* normalizePathname(" ");
|
|
533
|
+
* // ➔ "/"
|
|
381
534
|
*/
|
|
382
|
-
declare
|
|
535
|
+
declare function normalizePathname<T>(pathname:T,options?:NormalizePathnameOptionsKeepNullableFalse):ResUnKeepNullable<T>;declare function normalizePathname<T>(pathname:T,options?:NormalizePathnameOptionsKeepNullableTrue):ResKeepNullable<T>;type FormatEnvPortOptions={
|
|
383
536
|
/** Add prefix with a colon, defaultValue: `false`.
|
|
384
537
|
*
|
|
385
538
|
* @default false
|
|
@@ -404,4 +557,100 @@ prefixColon?:boolean;};
|
|
|
404
557
|
* formatEnvPort("port:8080", { prefixColon: true });
|
|
405
558
|
* // ➔ ":8080"
|
|
406
559
|
*/
|
|
407
|
-
declare const formatEnvPort:(envVar:string|null|undefined,options?:FormatEnvPortOptions)=>string;
|
|
560
|
+
declare const formatEnvPort:(envVar:string|null|undefined,options?:FormatEnvPortOptions)=>string;
|
|
561
|
+
/** ---------------------------------------------------------
|
|
562
|
+
* * ***Constants for `Punycode-UtilsJS` algorithm.***
|
|
563
|
+
* ---------------------------------------------------------
|
|
564
|
+
* These constants are used internally for encoding and decoding.
|
|
565
|
+
*
|
|
566
|
+
* Unicode domain names to ASCII (`Punycode-UtilsJS`) and vice versa.
|
|
567
|
+
*/
|
|
568
|
+
type PunycodeUtilsJS={
|
|
569
|
+
/** ---------------------------------------------------------
|
|
570
|
+
* * ***Version of the `Punycode-UtilsJS` implementation.***
|
|
571
|
+
* ---------------------------------------------------------
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* console.log(punycodeUtilsJS.version); // "1.0.0"
|
|
575
|
+
*/
|
|
576
|
+
version:string;
|
|
577
|
+
/** ---------------------------------------------------------
|
|
578
|
+
* * ***UCS-2 utility functions.***
|
|
579
|
+
* ---------------------------------------------------------
|
|
580
|
+
*/
|
|
581
|
+
ucs2:{
|
|
582
|
+
/** ---------------------------------------------------------
|
|
583
|
+
* * ***Decodes a UCS-2 encoded string to an array of Unicode code points.***
|
|
584
|
+
* ---------------------------------------------------------
|
|
585
|
+
*
|
|
586
|
+
* @param input - The UCS-2 string to decode.
|
|
587
|
+
* @returns Array of Unicode code points.
|
|
588
|
+
* @example
|
|
589
|
+
* punycodeUtilsJS.ucs2.decode("𐍈");
|
|
590
|
+
* // ➔ [66376]
|
|
591
|
+
*/
|
|
592
|
+
decode:(input:string)=>number[];
|
|
593
|
+
/** ---------------------------------------------------------
|
|
594
|
+
* * ***Encodes an array of Unicode code points to a UCS-2 string.***
|
|
595
|
+
* ---------------------------------------------------------
|
|
596
|
+
*
|
|
597
|
+
* @param points - Array of Unicode code points.
|
|
598
|
+
* @returns Encoded string.
|
|
599
|
+
* @example
|
|
600
|
+
* punycodeUtilsJS.ucs2.encode([66376]);
|
|
601
|
+
* // ➔ "𐍈"
|
|
602
|
+
*/
|
|
603
|
+
encode:(points:number[])=>string;};
|
|
604
|
+
/** ---------------------------------------------------------
|
|
605
|
+
* * ***Decodes a `Punycode-UtilsJS` string to a Unicode string.***
|
|
606
|
+
* ---------------------------------------------------------
|
|
607
|
+
*
|
|
608
|
+
* @param input - The `Punycode-UtilsJS` string to decode.
|
|
609
|
+
* @returns Decoded Unicode string.
|
|
610
|
+
* @example
|
|
611
|
+
* punycodeUtilsJS.decode("xn--fsq");
|
|
612
|
+
* // ➔ "ü"
|
|
613
|
+
*/
|
|
614
|
+
decode:(input:string)=>string;
|
|
615
|
+
/** ---------------------------------------------------------
|
|
616
|
+
* * ***Encodes a Unicode string to `Punycode-UtilsJS`.***
|
|
617
|
+
* ---------------------------------------------------------
|
|
618
|
+
*
|
|
619
|
+
* @param input - Unicode string to encode.
|
|
620
|
+
* @returns `Punycode-UtilsJS` string.
|
|
621
|
+
* @example
|
|
622
|
+
* punycodeUtilsJS.encode("ü");
|
|
623
|
+
* // ➔ "xn--fsq"
|
|
624
|
+
*/
|
|
625
|
+
encode:(input:string)=>string;
|
|
626
|
+
/** ---------------------------------------------------------
|
|
627
|
+
* * ***Converts a Unicode domain or label to ASCII (`Punycode-UtilsJS`).***
|
|
628
|
+
* ---------------------------------------------------------
|
|
629
|
+
*
|
|
630
|
+
* @param input - Domain or label string.
|
|
631
|
+
* @returns ASCII string suitable for DNS.
|
|
632
|
+
* @example
|
|
633
|
+
* punycodeUtilsJS.toASCII("пример.рф");
|
|
634
|
+
* // ➔ "xn--e1afmkfd.xn--p1ai"
|
|
635
|
+
*/
|
|
636
|
+
toASCII:(input:string)=>string;
|
|
637
|
+
/** ---------------------------------------------------------
|
|
638
|
+
* * ***Converts an ASCII (`Punycode-UtilsJS`) domain or label to Unicode.***
|
|
639
|
+
* ---------------------------------------------------------
|
|
640
|
+
*
|
|
641
|
+
* @param input - ASCII string (with xn-- prefix if needed).
|
|
642
|
+
* @returns Unicode string.
|
|
643
|
+
* @example
|
|
644
|
+
* punycodeUtilsJS.toUnicode("xn--e1afmkfd.xn--p1ai");
|
|
645
|
+
* // ➔ "пример.рф"
|
|
646
|
+
*/
|
|
647
|
+
toUnicode:(input:string)=>string;};
|
|
648
|
+
/** ---------------------------------------------------------
|
|
649
|
+
* * ***`Punycode-UtilsJS` object exposing all API functions and version.***
|
|
650
|
+
* ---------------------------------------------------------
|
|
651
|
+
* Provides encoding and decoding of Unicode domain names to ASCII (`Punycode-UtilsJS`)
|
|
652
|
+
* and vice versa.
|
|
653
|
+
*
|
|
654
|
+
* - Useful for IDN (Internationalized Domain Names) support.
|
|
655
|
+
*/
|
|
656
|
+
declare const punycodeUtilsJS:PunycodeUtilsJS;export{type QueryParamPairs,constructURL,extractURLs,formatEnvPort,getFirstPrefixPathname,getPrefixPathname,normalizePathname,punycodeUtilsJS};
|
package/dist/urls/index.js
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.6.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-6PKW4WCT.js';
|
|
11
11
|
import '../chunk-ONZFBJVW.js';
|
|
12
12
|
import '../chunk-GAJBF6DR.js';
|
|
13
13
|
import '../chunk-TDYGYHSH.js';
|
|
14
14
|
import '../chunk-PZQC3FZY.js';
|
|
15
15
|
import '../chunk-7ZNEUWYP.js';
|
|
16
16
|
import '../chunk-WVSPXFTY.js';
|
|
17
|
-
export { formatEnvPort, normalizePathname } from '../chunk-
|
|
17
|
+
export { formatEnvPort, normalizePathname } from '../chunk-WNO3EPYT.js';
|
|
18
|
+
export { punycodeUtilsJS } from '../chunk-YS27V6LS.js';
|
|
18
19
|
import '../chunk-4ACKNPL5.js';
|
|
19
20
|
import '../chunk-JY4HLZ4W.js';
|
|
20
21
|
import '../chunk-VCVND6CH.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rzl-zone/utils-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -191,16 +191,25 @@
|
|
|
191
191
|
"keywords": [
|
|
192
192
|
"javascript",
|
|
193
193
|
"typescript",
|
|
194
|
+
"js",
|
|
195
|
+
"ts",
|
|
196
|
+
"util",
|
|
194
197
|
"utils",
|
|
198
|
+
"helper",
|
|
195
199
|
"helpers",
|
|
196
200
|
"library",
|
|
197
201
|
"@rzl-zone/utils-js",
|
|
198
202
|
"rzl",
|
|
199
203
|
"rzl-zone",
|
|
204
|
+
"rzl zone",
|
|
205
|
+
"util js",
|
|
206
|
+
"util-js",
|
|
200
207
|
"utils-js",
|
|
208
|
+
"utils js",
|
|
201
209
|
"utility",
|
|
210
|
+
"utility js",
|
|
202
211
|
"rzl-utils",
|
|
203
|
-
"
|
|
212
|
+
"rzl utils",
|
|
204
213
|
"functions"
|
|
205
214
|
],
|
|
206
215
|
"publishConfig": {
|
package/dist/chunk-LBNOZIZ6.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.5.7.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
import { removeSpaces } from './chunk-4ACKNPL5.js';
|
|
11
|
-
import { isEmptyString } from './chunk-JY4HLZ4W.js';
|
|
12
|
-
import { safeStableStringify } from './chunk-2VO2CBTU.js';
|
|
13
|
-
import { isNonEmptyString, getPreciseType, isError, assertIsPlainObject, hasOwnProp, isBoolean, isFunction } from './chunk-3KTD3QDI.js';
|
|
14
|
-
|
|
15
|
-
var NormalizePathnameError = class _NormalizePathnameError extends Error {
|
|
16
|
-
/** * ***The original error that triggered this normalization failure.***
|
|
17
|
-
*
|
|
18
|
-
* **Always available for backward compatibility.**
|
|
19
|
-
*/
|
|
20
|
-
originalError;
|
|
21
|
-
constructor(message, originalError) {
|
|
22
|
-
super(message, isFunction(Error) ? { cause: originalError } : void 0);
|
|
23
|
-
this.name = "NormalizePathnameError";
|
|
24
|
-
this.originalError = originalError;
|
|
25
|
-
if (isFunction(Error.captureStackTrace)) {
|
|
26
|
-
Error.captureStackTrace(this, _NormalizePathnameError);
|
|
27
|
-
} else {
|
|
28
|
-
this.stack = new Error(message).stack;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/** * ***Safe JSON representation for logging or IPC.*** */
|
|
32
|
-
toJSON() {
|
|
33
|
-
return {
|
|
34
|
-
name: this.name,
|
|
35
|
-
message: this.message,
|
|
36
|
-
stack: this.stack,
|
|
37
|
-
originalError: {
|
|
38
|
-
name: this.originalError.name,
|
|
39
|
-
message: this.originalError.message,
|
|
40
|
-
stack: this.originalError.stack
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var normalizePathname = (pathname, defaultPath = "/") => {
|
|
47
|
-
if (!isNonEmptyString(defaultPath)) {
|
|
48
|
-
throw new TypeError(
|
|
49
|
-
`Second parameter (\`defaultPath\`) must be of type \`string\` and not empty-string, but received: \`${getPreciseType(
|
|
50
|
-
defaultPath
|
|
51
|
-
)}\`, with value: \`${safeStableStringify(defaultPath)}\`.`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
if (!isNonEmptyString(pathname)) return defaultPath;
|
|
55
|
-
try {
|
|
56
|
-
pathname = removeSpaces(pathname, { trimOnly: true });
|
|
57
|
-
pathname = pathname.replace(/\s+/g, "");
|
|
58
|
-
if (pathname.startsWith("http://") || pathname.startsWith("https://")) {
|
|
59
|
-
const url = new URL(pathname);
|
|
60
|
-
return `${url.pathname}${url.search}${url.hash}`.replace(/^\/+/, "/");
|
|
61
|
-
}
|
|
62
|
-
return "/" + pathname.replace(/^\/+/, "").replace(/\/{2,}/g, "/");
|
|
63
|
-
} catch (error) {
|
|
64
|
-
const err = isError(error) ? error : new Error("Unknown error from function `normalizePathname()`.");
|
|
65
|
-
throw new NormalizePathnameError(
|
|
66
|
-
`Failed to normalize pathname in function \`normalizePathname()\`: ${err.message}`,
|
|
67
|
-
err
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
var formatEnvPort = (envVar, options = {}) => {
|
|
73
|
-
if (!isNonEmptyString(envVar)) return "";
|
|
74
|
-
assertIsPlainObject(options, {
|
|
75
|
-
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
76
|
-
});
|
|
77
|
-
const prefixColon = hasOwnProp(options, "prefixColon") ? options.prefixColon : false;
|
|
78
|
-
if (!isBoolean(prefixColon)) {
|
|
79
|
-
throw new TypeError(
|
|
80
|
-
`Parameter \`prefixColon\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: \`${getPreciseType(
|
|
81
|
-
prefixColon
|
|
82
|
-
)}\`.`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
const digitsOnly = envVar.replace(/\D+/g, "");
|
|
86
|
-
if (isEmptyString(digitsOnly)) return "";
|
|
87
|
-
return prefixColon ? `:${digitsOnly}` : digitsOnly;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export { formatEnvPort, normalizePathname };
|