♻️ 换一种写法

This commit is contained in:
BTMuli
2023-05-19 10:37:04 +08:00
parent 07609a8c36
commit eba15f9c4c

View File

@@ -70,14 +70,16 @@ export function qs (obj: Record<string, string>, encode: boolean = false): strin
} }
/** /**
* @description 将 ck JSON 对象转换为字符串 * @description 将 cookie 对象转换为字符串
* @since Alpha v0.2.0 * @since Alpha v0.2.0
* @param {object} ck ck JSON 对象 * @param {Record<string, string>} cookie cookie
* @returns {string} ck 字符串 * @returns {string} 转换后的 cookie
*/ */
export function cookieToString (ck: object): string { export function transCookie (cookie: Record<string, string>) {
let res = stringify(ck); let res = "";
res = res.replace(/&/g, ";"); for (const [key, value] of Object.entries(cookie)) {
res += `${key}=${value};`;
}
return res; return res;
} }