@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.iife.js
CHANGED
|
@@ -237,6 +237,15 @@ var Utils = (function () {
|
|
|
237
237
|
this.windowApi = Object.assign({}, windowApiOption);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* 获取Cookie分组
|
|
242
|
+
*/
|
|
243
|
+
getCookiesList() {
|
|
244
|
+
if (this.windowApi.document.cookie.trim() === "") {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
return this.windowApi.document.cookie.split(";");
|
|
248
|
+
}
|
|
240
249
|
/**
|
|
241
250
|
* 获取单个cookie
|
|
242
251
|
* @param cookieName cookie名
|
|
@@ -245,7 +254,7 @@ var Utils = (function () {
|
|
|
245
254
|
if (typeof cookieName !== "string") {
|
|
246
255
|
throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
|
|
247
256
|
}
|
|
248
|
-
let cookies = this.
|
|
257
|
+
let cookies = this.getCookiesList();
|
|
249
258
|
let findValue = undefined;
|
|
250
259
|
for (const cookieItem of cookies) {
|
|
251
260
|
let item = cookieItem.trim();
|
|
@@ -291,7 +300,7 @@ var Utils = (function () {
|
|
|
291
300
|
path: "/",
|
|
292
301
|
};
|
|
293
302
|
defaultOption = utils.assign(defaultOption, option);
|
|
294
|
-
let cookies = this.
|
|
303
|
+
let cookies = this.getCookiesList();
|
|
295
304
|
cookies.forEach((item) => {
|
|
296
305
|
item = item.trim();
|
|
297
306
|
let itemSplit = item.split("=");
|
|
@@ -342,7 +351,7 @@ var Utils = (function () {
|
|
|
342
351
|
path: "/",
|
|
343
352
|
};
|
|
344
353
|
defaultOption = utils.assign(defaultOption, option);
|
|
345
|
-
let cookies = this.
|
|
354
|
+
let cookies = this.getCookiesList();
|
|
346
355
|
cookies.forEach((item) => {
|
|
347
356
|
item = item.trim();
|
|
348
357
|
let itemSplit = item.split("=");
|
|
@@ -450,6 +459,9 @@ var Utils = (function () {
|
|
|
450
459
|
* @param cookieStr
|
|
451
460
|
*/
|
|
452
461
|
parseCookie(cookieStr) {
|
|
462
|
+
if (cookieStr.trim() === "") {
|
|
463
|
+
return [];
|
|
464
|
+
}
|
|
453
465
|
let cookies = cookieStr.split(";");
|
|
454
466
|
let result = [];
|
|
455
467
|
for (const cookieItem of cookies) {
|