@deot/helper-route 1.1.3 → 1.1.4
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 +4 -2
- package/dist/index.cjs +5 -5
- package/dist/index.iife.js +8 -8
- package/dist/index.js +5 -5
- package/dist/index.umd.cjs +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -28,9 +28,9 @@ const merge = (route) => {
|
|
|
28
28
|
let result = origin;
|
|
29
29
|
result += path instanceof Array ? path.length ? `/${path.join("/")}` : "" : path;
|
|
30
30
|
let queryArr = [];
|
|
31
|
-
for (
|
|
31
|
+
for (const key in query) {
|
|
32
32
|
if (query[key] || query[key] === false || query[key] === 0) {
|
|
33
|
-
|
|
33
|
+
const v = helperUtils.flatten(query[key]);
|
|
34
34
|
queryArr = [
|
|
35
35
|
...queryArr,
|
|
36
36
|
`${key}=${encodeURIComponent(v)}`
|
|
@@ -54,9 +54,9 @@ const parse = (url, options) => {
|
|
|
54
54
|
const query = {};
|
|
55
55
|
if (search) {
|
|
56
56
|
Array.from(search.match(/[^?=&]+=[^&]*/g) || []).forEach((v) => {
|
|
57
|
-
|
|
58
|
-
value = helperUtils.flatten(value);
|
|
59
|
-
query[key] = typeof options$.parse === "function" ? options$.parse(value) : value
|
|
57
|
+
const [key, value] = v.split("=");
|
|
58
|
+
const value$ = helperUtils.flatten(value);
|
|
59
|
+
query[key] = typeof options$.parse === "function" ? options$.parse(value$) : value$;
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
const sIndex = prefix.indexOf("/");
|
package/dist/index.iife.js
CHANGED
|
@@ -10,12 +10,12 @@ var HelperRoute = (function (exports) {
|
|
|
10
10
|
throw new Error(value);
|
|
11
11
|
}
|
|
12
12
|
try {
|
|
13
|
-
|
|
13
|
+
const next = (parser || decodeURIComponent)(parseValue);
|
|
14
14
|
if (parseValue === next) {
|
|
15
15
|
need = false;
|
|
16
16
|
}
|
|
17
17
|
parseValue = next;
|
|
18
|
-
} catch {
|
|
18
|
+
} catch (_) {
|
|
19
19
|
need = false;
|
|
20
20
|
}
|
|
21
21
|
safeCount++;
|
|
@@ -26,7 +26,7 @@ var HelperRoute = (function (exports) {
|
|
|
26
26
|
const flattenJSONParse = (value) => {
|
|
27
27
|
if (value === null)
|
|
28
28
|
return null;
|
|
29
|
-
|
|
29
|
+
const regex = /^\d+$/;
|
|
30
30
|
if (regex.test(value) && value.length >= 16 && +value > Number.MAX_SAFE_INTEGER) {
|
|
31
31
|
return value;
|
|
32
32
|
}
|
|
@@ -57,9 +57,9 @@ var HelperRoute = (function (exports) {
|
|
|
57
57
|
let result = origin;
|
|
58
58
|
result += path instanceof Array ? path.length ? `/${path.join("/")}` : "" : path;
|
|
59
59
|
let queryArr = [];
|
|
60
|
-
for (
|
|
60
|
+
for (const key in query) {
|
|
61
61
|
if (query[key] || query[key] === false || query[key] === 0) {
|
|
62
|
-
|
|
62
|
+
const v = flatten(query[key]);
|
|
63
63
|
queryArr = [
|
|
64
64
|
...queryArr,
|
|
65
65
|
`${key}=${encodeURIComponent(v)}`
|
|
@@ -83,9 +83,9 @@ var HelperRoute = (function (exports) {
|
|
|
83
83
|
const query = {};
|
|
84
84
|
if (search) {
|
|
85
85
|
Array.from(search.match(/[^?=&]+=[^&]*/g) || []).forEach((v) => {
|
|
86
|
-
|
|
87
|
-
value = flatten(value);
|
|
88
|
-
query[key] = typeof options$.parse === "function" ? options$.parse(value) : value
|
|
86
|
+
const [key, value] = v.split("=");
|
|
87
|
+
const value$ = flatten(value);
|
|
88
|
+
query[key] = typeof options$.parse === "function" ? options$.parse(value$) : value$;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
const sIndex = prefix.indexOf("/");
|
package/dist/index.js
CHANGED
|
@@ -24,9 +24,9 @@ const merge = (route) => {
|
|
|
24
24
|
let result = origin;
|
|
25
25
|
result += path instanceof Array ? path.length ? `/${path.join("/")}` : "" : path;
|
|
26
26
|
let queryArr = [];
|
|
27
|
-
for (
|
|
27
|
+
for (const key in query) {
|
|
28
28
|
if (query[key] || query[key] === false || query[key] === 0) {
|
|
29
|
-
|
|
29
|
+
const v = flatten(query[key]);
|
|
30
30
|
queryArr = [
|
|
31
31
|
...queryArr,
|
|
32
32
|
`${key}=${encodeURIComponent(v)}`
|
|
@@ -50,9 +50,9 @@ const parse = (url, options) => {
|
|
|
50
50
|
const query = {};
|
|
51
51
|
if (search) {
|
|
52
52
|
Array.from(search.match(/[^?=&]+=[^&]*/g) || []).forEach((v) => {
|
|
53
|
-
|
|
54
|
-
value = flatten(value);
|
|
55
|
-
query[key] = typeof options$.parse === "function" ? options$.parse(value) : value
|
|
53
|
+
const [key, value] = v.split("=");
|
|
54
|
+
const value$ = flatten(value);
|
|
55
|
+
query[key] = typeof options$.parse === "function" ? options$.parse(value$) : value$;
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
const sIndex = prefix.indexOf("/");
|
package/dist/index.umd.cjs
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
throw new Error(value);
|
|
14
14
|
}
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
const next = (parser || decodeURIComponent)(parseValue);
|
|
17
17
|
if (parseValue === next) {
|
|
18
18
|
need = false;
|
|
19
19
|
}
|
|
20
20
|
parseValue = next;
|
|
21
|
-
} catch {
|
|
21
|
+
} catch (_) {
|
|
22
22
|
need = false;
|
|
23
23
|
}
|
|
24
24
|
safeCount++;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
const flattenJSONParse = (value) => {
|
|
30
30
|
if (value === null)
|
|
31
31
|
return null;
|
|
32
|
-
|
|
32
|
+
const regex = /^\d+$/;
|
|
33
33
|
if (regex.test(value) && value.length >= 16 && +value > Number.MAX_SAFE_INTEGER) {
|
|
34
34
|
return value;
|
|
35
35
|
}
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
let result = origin;
|
|
61
61
|
result += path instanceof Array ? path.length ? `/${path.join("/")}` : "" : path;
|
|
62
62
|
let queryArr = [];
|
|
63
|
-
for (
|
|
63
|
+
for (const key in query) {
|
|
64
64
|
if (query[key] || query[key] === false || query[key] === 0) {
|
|
65
|
-
|
|
65
|
+
const v = flatten(query[key]);
|
|
66
66
|
queryArr = [
|
|
67
67
|
...queryArr,
|
|
68
68
|
`${key}=${encodeURIComponent(v)}`
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
const query = {};
|
|
87
87
|
if (search) {
|
|
88
88
|
Array.from(search.match(/[^?=&]+=[^&]*/g) || []).forEach((v) => {
|
|
89
|
-
|
|
90
|
-
value = flatten(value);
|
|
91
|
-
query[key] = typeof options$.parse === "function" ? options$.parse(value) : value
|
|
89
|
+
const [key, value] = v.split("=");
|
|
90
|
+
const value$ = flatten(value);
|
|
91
|
+
query[key] = typeof options$.parse === "function" ? options$.parse(value$) : value$;
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
const sIndex = prefix.indexOf("/");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/helper-route",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@deot/helper-utils": "^1.1.
|
|
22
|
+
"@deot/helper-utils": "^1.1.4"
|
|
23
23
|
}
|
|
24
24
|
}
|