@whitesev/utils 2.6.2 → 2.6.3
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.
- package/dist/index.amd.js +10 -4
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +10 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +10 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +10 -4
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +10 -4
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +10 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/types/UtilsGMCookie.d.ts +2 -2
- package/package.json +1 -1
- package/src/Utils.ts +1 -1
- package/src/UtilsGMCookie.ts +9 -3
- package/src/types/UtilsGMCookie.d.ts +2 -2
|
@@ -41,7 +41,8 @@ export interface UtilsGMCookieSetOptions {
|
|
|
41
41
|
url?: string;
|
|
42
42
|
/**
|
|
43
43
|
* Cookie所在域
|
|
44
|
-
*
|
|
44
|
+
*
|
|
45
|
+
* 不填的话会默认在window.location.hostname的前面加上.
|
|
45
46
|
*/
|
|
46
47
|
domain?: string;
|
|
47
48
|
/** 需要检索的Cookie的名字 */
|
|
@@ -82,7 +83,6 @@ export interface UtilsGMCookieDeleteOptions {
|
|
|
82
83
|
path?: string;
|
|
83
84
|
/**
|
|
84
85
|
* Cookie所在域
|
|
85
|
-
* @default window.location.hostname
|
|
86
86
|
*/
|
|
87
87
|
firstPartyDomain?: string;
|
|
88
88
|
}
|
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
package/src/UtilsGMCookie.ts
CHANGED
|
@@ -166,7 +166,7 @@ export class UtilsGMCookie {
|
|
|
166
166
|
url: this.windowApi.window.location.href,
|
|
167
167
|
name: "",
|
|
168
168
|
value: "",
|
|
169
|
-
domain:
|
|
169
|
+
domain: "",
|
|
170
170
|
path: "/",
|
|
171
171
|
secure: true,
|
|
172
172
|
httpOnly: false,
|
|
@@ -186,6 +186,9 @@ export class UtilsGMCookie {
|
|
|
186
186
|
";expires=" +
|
|
187
187
|
(new Date(life) as any).toGMTString() +
|
|
188
188
|
"; path=/";
|
|
189
|
+
if (Utils.isNotNull(defaultOption.domain)) {
|
|
190
|
+
cookieStr += "; domain=" + defaultOption.domain;
|
|
191
|
+
}
|
|
189
192
|
this.windowApi.document.cookie = cookieStr;
|
|
190
193
|
} catch (error: any) {
|
|
191
194
|
errorInfo = error;
|
|
@@ -210,10 +213,13 @@ export class UtilsGMCookie {
|
|
|
210
213
|
url: this.windowApi.window.location.href,
|
|
211
214
|
name: "",
|
|
212
215
|
path: "/",
|
|
213
|
-
firstPartyDomain:
|
|
216
|
+
firstPartyDomain: "",
|
|
214
217
|
};
|
|
215
218
|
defaultOption = Utils.assign(defaultOption, option);
|
|
216
|
-
let cookieStr = `${defaultOption.name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${defaultOption.path}
|
|
219
|
+
let cookieStr = `${defaultOption.name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${defaultOption.path}`;
|
|
220
|
+
if (Utils.isNotNull(defaultOption.firstPartyDomain)) {
|
|
221
|
+
cookieStr += `; domain=${defaultOption.firstPartyDomain};`;
|
|
222
|
+
}
|
|
217
223
|
this.windowApi.document.cookie = cookieStr;
|
|
218
224
|
} catch (error: any) {
|
|
219
225
|
errorInfo = error;
|
|
@@ -41,7 +41,8 @@ export interface UtilsGMCookieSetOptions {
|
|
|
41
41
|
url?: string;
|
|
42
42
|
/**
|
|
43
43
|
* Cookie所在域
|
|
44
|
-
*
|
|
44
|
+
*
|
|
45
|
+
* 不填的话会默认在window.location.hostname的前面加上.
|
|
45
46
|
*/
|
|
46
47
|
domain?: string;
|
|
47
48
|
/** 需要检索的Cookie的名字 */
|
|
@@ -82,7 +83,6 @@ export interface UtilsGMCookieDeleteOptions {
|
|
|
82
83
|
path?: string;
|
|
83
84
|
/**
|
|
84
85
|
* Cookie所在域
|
|
85
|
-
* @default window.location.hostname
|
|
86
86
|
*/
|
|
87
87
|
firstPartyDomain?: string;
|
|
88
88
|
}
|