@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.
@@ -239,6 +239,15 @@ System.register('Utils', [], (function (exports) {
239
239
  this.windowApi = Object.assign({}, windowApiOption);
240
240
  }
241
241
  }
242
+ /**
243
+ * 获取Cookie分组
244
+ */
245
+ getCookiesList() {
246
+ if (this.windowApi.document.cookie.trim() === "") {
247
+ return [];
248
+ }
249
+ return this.windowApi.document.cookie.split(";");
250
+ }
242
251
  /**
243
252
  * 获取单个cookie
244
253
  * @param cookieName cookie名
@@ -247,7 +256,7 @@ System.register('Utils', [], (function (exports) {
247
256
  if (typeof cookieName !== "string") {
248
257
  throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
249
258
  }
250
- let cookies = this.windowApi.document.cookie.split(";");
259
+ let cookies = this.getCookiesList();
251
260
  let findValue = undefined;
252
261
  for (const cookieItem of cookies) {
253
262
  let item = cookieItem.trim();
@@ -293,7 +302,7 @@ System.register('Utils', [], (function (exports) {
293
302
  path: "/",
294
303
  };
295
304
  defaultOption = utils.assign(defaultOption, option);
296
- let cookies = this.windowApi.document.cookie.split(";");
305
+ let cookies = this.getCookiesList();
297
306
  cookies.forEach((item) => {
298
307
  item = item.trim();
299
308
  let itemSplit = item.split("=");
@@ -344,7 +353,7 @@ System.register('Utils', [], (function (exports) {
344
353
  path: "/",
345
354
  };
346
355
  defaultOption = utils.assign(defaultOption, option);
347
- let cookies = this.windowApi.document.cookie.split(";");
356
+ let cookies = this.getCookiesList();
348
357
  cookies.forEach((item) => {
349
358
  item = item.trim();
350
359
  let itemSplit = item.split("=");
@@ -452,6 +461,9 @@ System.register('Utils', [], (function (exports) {
452
461
  * @param cookieStr
453
462
  */
454
463
  parseCookie(cookieStr) {
464
+ if (cookieStr.trim() === "") {
465
+ return [];
466
+ }
455
467
  let cookies = cookieStr.split(";");
456
468
  let result = [];
457
469
  for (const cookieItem of cookies) {