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