mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
♻️ 换一种写法
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user