From 2a4e1111602dbe46bb0af803f6f3a36c8ea910fe Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 12 Dec 2024 14:38:37 +0100 Subject: [PATCH] Updates --- package-shared/utils/serialize-query.js | 13 ++++++++++++- package.json | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package-shared/utils/serialize-query.js b/package-shared/utils/serialize-query.js index 7c3670f..d2a8f47 100644 --- a/package-shared/utils/serialize-query.js +++ b/package-shared/utils/serialize-query.js @@ -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; } diff --git a/package.json b/package.json index c60453a..f309a8d 100644 --- a/package.json +++ b/package.json @@ -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": {