From eba15f9c4cd33c51a8c75ea61cb423a586864ba8 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Fri, 19 May 2023 10:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E6=8D=A2=E4=B8=80?= =?UTF-8?q?=E7=A7=8D=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/utils/tools.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/web/utils/tools.ts b/src/web/utils/tools.ts index f293f394..35c8f28d 100644 --- a/src/web/utils/tools.ts +++ b/src/web/utils/tools.ts @@ -70,14 +70,16 @@ export function qs (obj: Record, encode: boolean = false): strin } /** - * @description 将 ck JSON 对象转换为字符串 + * @description 将 cookie 对象转换为字符串 * @since Alpha v0.2.0 - * @param {object} ck ck JSON 对象 - * @returns {string} ck 字符串 + * @param {Record} cookie cookie + * @returns {string} 转换后的 cookie */ -export function cookieToString (ck: object): string { - let res = stringify(ck); - res = res.replace(/&/g, ";"); +export function transCookie (cookie: Record) { + let res = ""; + for (const [key, value] of Object.entries(cookie)) { + res += `${key}=${value};`; + } return res; }