@whitesev/utils 2.6.3 → 2.6.4
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 +15 -3
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +15 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +15 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +15 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +15 -3
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +15 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/UtilsGMCookie.d.ts +4 -0
- package/package.json +1 -1
- package/src/UtilsGMCookie.ts +15 -4
package/dist/index.cjs.js
CHANGED
|
@@ -236,6 +236,15 @@ class UtilsGMCookie {
|
|
|
236
236
|
this.windowApi = Object.assign({}, windowApiOption);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* 获取Cookie分组
|
|
241
|
+
*/
|
|
242
|
+
getCookiesList() {
|
|
243
|
+
if (this.windowApi.document.cookie.trim() === "") {
|
|
244
|
+
return [];
|
|
245
|
+
}
|
|
246
|
+
return this.windowApi.document.cookie.split(";");
|
|
247
|
+
}
|
|
239
248
|
/**
|
|
240
249
|
* 获取单个cookie
|
|
241
250
|
* @param cookieName cookie名
|
|
@@ -244,7 +253,7 @@ class UtilsGMCookie {
|
|
|
244
253
|
if (typeof cookieName !== "string") {
|
|
245
254
|
throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
|
|
246
255
|
}
|
|
247
|
-
let cookies = this.
|
|
256
|
+
let cookies = this.getCookiesList();
|
|
248
257
|
let findValue = undefined;
|
|
249
258
|
for (const cookieItem of cookies) {
|
|
250
259
|
let item = cookieItem.trim();
|
|
@@ -290,7 +299,7 @@ class UtilsGMCookie {
|
|
|
290
299
|
path: "/",
|
|
291
300
|
};
|
|
292
301
|
defaultOption = utils.assign(defaultOption, option);
|
|
293
|
-
let cookies = this.
|
|
302
|
+
let cookies = this.getCookiesList();
|
|
294
303
|
cookies.forEach((item) => {
|
|
295
304
|
item = item.trim();
|
|
296
305
|
let itemSplit = item.split("=");
|
|
@@ -341,7 +350,7 @@ class UtilsGMCookie {
|
|
|
341
350
|
path: "/",
|
|
342
351
|
};
|
|
343
352
|
defaultOption = utils.assign(defaultOption, option);
|
|
344
|
-
let cookies = this.
|
|
353
|
+
let cookies = this.getCookiesList();
|
|
345
354
|
cookies.forEach((item) => {
|
|
346
355
|
item = item.trim();
|
|
347
356
|
let itemSplit = item.split("=");
|
|
@@ -449,6 +458,9 @@ class UtilsGMCookie {
|
|
|
449
458
|
* @param cookieStr
|
|
450
459
|
*/
|
|
451
460
|
parseCookie(cookieStr) {
|
|
461
|
+
if (cookieStr.trim() === "") {
|
|
462
|
+
return [];
|
|
463
|
+
}
|
|
452
464
|
let cookies = cookieStr.split(";");
|
|
453
465
|
let result = [];
|
|
454
466
|
for (const cookieItem of cookies) {
|