@uniqu/url 0.1.3 → 0.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/dist/builder.cjs +3 -3
- package/dist/builder.mjs +3 -3
- package/package.json +2 -2
package/dist/builder.cjs
CHANGED
|
@@ -37,7 +37,7 @@ function serializeFilter(expr) {
|
|
|
37
37
|
}
|
|
38
38
|
let result = "";
|
|
39
39
|
for (const [field, value] of Object.entries(expr)) if (value instanceof RegExp) {
|
|
40
|
-
const part = `${field}
|
|
40
|
+
const part = `${field}~=${serializeValue(value)}`;
|
|
41
41
|
result = result ? result + "&" + part : part;
|
|
42
42
|
} else if ((0, _uniqu_core.isPrimitive)(value)) {
|
|
43
43
|
const part = `${field}=${serializeValue(value)}`;
|
|
@@ -82,12 +82,12 @@ function serializeValue(value) {
|
|
|
82
82
|
if (value === true) return "true";
|
|
83
83
|
if (value === false) return "false";
|
|
84
84
|
if (typeof value === "number") return String(value);
|
|
85
|
-
if (value instanceof RegExp) return value.toString()
|
|
85
|
+
if (value instanceof RegExp) return `'${value.toString()}'`;
|
|
86
86
|
if (value instanceof Date) return `'${value.toISOString()}'`;
|
|
87
87
|
const str = String(value);
|
|
88
88
|
if (str === "null" || str === "true" || str === "false") return `'${str}'`;
|
|
89
89
|
if (/^\d/.test(str) && !isNaN(Number(str)) && !str.startsWith("0")) return `'${str}'`;
|
|
90
|
-
if (str.startsWith("/") && /\/[gimsuy]*$/.test(str)) return str
|
|
90
|
+
if (str.startsWith("/") && /\/[gimsuy]*$/.test(str)) return `'${str}'`;
|
|
91
91
|
if (/[&^=!<>~(){},\s'\\]/.test(str)) return `'${str.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
92
92
|
return str;
|
|
93
93
|
}
|
package/dist/builder.mjs
CHANGED
|
@@ -36,7 +36,7 @@ function serializeFilter(expr) {
|
|
|
36
36
|
}
|
|
37
37
|
let result = "";
|
|
38
38
|
for (const [field, value] of Object.entries(expr)) if (value instanceof RegExp) {
|
|
39
|
-
const part = `${field}
|
|
39
|
+
const part = `${field}~=${serializeValue(value)}`;
|
|
40
40
|
result = result ? result + "&" + part : part;
|
|
41
41
|
} else if (isPrimitive(value)) {
|
|
42
42
|
const part = `${field}=${serializeValue(value)}`;
|
|
@@ -81,12 +81,12 @@ function serializeValue(value) {
|
|
|
81
81
|
if (value === true) return "true";
|
|
82
82
|
if (value === false) return "false";
|
|
83
83
|
if (typeof value === "number") return String(value);
|
|
84
|
-
if (value instanceof RegExp) return value.toString()
|
|
84
|
+
if (value instanceof RegExp) return `'${value.toString()}'`;
|
|
85
85
|
if (value instanceof Date) return `'${value.toISOString()}'`;
|
|
86
86
|
const str = String(value);
|
|
87
87
|
if (str === "null" || str === "true" || str === "false") return `'${str}'`;
|
|
88
88
|
if (/^\d/.test(str) && !isNaN(Number(str)) && !str.startsWith("0")) return `'${str}'`;
|
|
89
|
-
if (str.startsWith("/") && /\/[gimsuy]*$/.test(str)) return str
|
|
89
|
+
if (str.startsWith("/") && /\/[gimsuy]*$/.test(str)) return `'${str}'`;
|
|
90
90
|
if (/[&^=!<>~(){},\s'\\]/.test(str)) return `'${str.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
91
91
|
return str;
|
|
92
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniqu/url",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "URL query string parser producing the Uniqu canonical query format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Artem Maltsev",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@uniqu/core": "^0.1.
|
|
48
|
+
"@uniqu/core": "^0.1.4"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"pub": "pnpm publish --access public",
|