Skip to content

Commit b3e4715

Browse files
authored
获取Cookie方法不健壮 (#162)
1 parent 8105763 commit b3e4715

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

bizyui/js/subassembly/tools.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ export const hideWidget = (node, widget_name) => {
1919
}
2020

2121
export function getCookie(name) {
22-
const value = `; ${document.cookie}`;
23-
const parts = value.split(`; ${name}=`);
24-
if (parts.length === 2) return parts.pop().split(';').shift();
22+
const cookies = document.cookie.split(';');
23+
for (let cookie of cookies) {
24+
const [key, ...valueParts] = cookie.trim().split('=');
25+
if (key === name) {
26+
return valueParts.join('=');
27+
}
28+
}
2529
return null;
2630
}
2731

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.89
1+
1.2.90

0 commit comments

Comments
 (0)