Updates
This commit is contained in:
parent
1c2798b93f
commit
2a4e111160
@ -1,5 +1,7 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
|
const EJSON = require("./ejson");
|
||||||
|
|
||||||
/** @type {import("../types").SerializeQueryFnType} */
|
/** @type {import("../types").SerializeQueryFnType} */
|
||||||
function serializeQuery({ query }) {
|
function serializeQuery({ query }) {
|
||||||
let str = "?";
|
let str = "?";
|
||||||
@ -7,10 +9,19 @@ function serializeQuery({ query }) {
|
|||||||
|
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
const queryArr = [];
|
const queryArr = [];
|
||||||
|
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
if (!key || !query[key]) return;
|
if (!key || !query[key]) return;
|
||||||
queryArr.push(`${key}=${query[key]}`);
|
const value = query[key];
|
||||||
|
|
||||||
|
if (typeof value === "object") {
|
||||||
|
const jsonStr = EJSON.stringify(value);
|
||||||
|
queryArr.push(`${key}=${encodeURIComponent(String(jsonStr))}`);
|
||||||
|
} else if (typeof value === "string" || typeof value === "number") {
|
||||||
|
queryArr.push(`${key}=${encodeURIComponent(value)}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
str += queryArr.join("&");
|
str += queryArr.join("&");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "3.0.7",
|
"version": "3.0.8",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user