uibee 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function getCookie(name: string): string | null;
|
|
2
2
|
export declare function setCookie(name: string, value: string, days?: number): void;
|
|
3
|
-
export declare function removeCookies(...cookies: string[]): void;
|
|
4
3
|
export declare function removeCookie(name: string): void;
|
|
4
|
+
export declare function removeCookies(...cookies: string[]): void;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export function getCookie(name) {
|
|
2
|
-
|
|
2
|
+
if (typeof document === 'undefined')
|
|
3
|
+
return null;
|
|
4
|
+
const matches = document.cookie.match(new RegExp('(?:^|; )' +
|
|
5
|
+
name.replace(/([.$?*|{}()[\]/\\+^])/g, '\\$1') +
|
|
6
|
+
'=([^;]*)'));
|
|
3
7
|
return matches ? decodeURIComponent(matches[1]) : null;
|
|
4
8
|
}
|
|
5
9
|
export function setCookie(name, value, days) {
|
|
10
|
+
if (typeof document === 'undefined')
|
|
11
|
+
return;
|
|
6
12
|
let expires = '';
|
|
7
13
|
if (!value) {
|
|
8
14
|
return;
|
|
@@ -16,13 +22,15 @@ export function setCookie(name, value, days) {
|
|
|
16
22
|
`${name}=${encodeURIComponent(value)}; ` +
|
|
17
23
|
`${expires} path=/; SameSite=Lax`;
|
|
18
24
|
}
|
|
19
|
-
export function removeCookies(...cookies) {
|
|
20
|
-
for (const cookie of cookies) {
|
|
21
|
-
removeCookie(cookie);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
25
|
export function removeCookie(name) {
|
|
26
|
+
if (typeof document === 'undefined')
|
|
27
|
+
return;
|
|
25
28
|
document.cookie =
|
|
26
29
|
`${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; ` +
|
|
27
30
|
'path=/; SameSite=Lax';
|
|
28
31
|
}
|
|
32
|
+
export function removeCookies(...cookies) {
|
|
33
|
+
for (const cookie of cookies) {
|
|
34
|
+
removeCookie(cookie);
|
|
35
|
+
}
|
|
36
|
+
}
|
package/package.json
CHANGED