@whitesev/utils 1.1.4 → 1.1.6

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.
@@ -270,28 +270,30 @@ System.register('Utils', [], (function (exports) {
270
270
  throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
271
271
  }
272
272
  let cookies = document.cookie.split(";");
273
- let findCookie = cookies.find((item) => {
274
- item = item.trimStart();
275
- let itemName = item.split("=")[0];
276
- let itemValue = item.replace(new RegExp("^" + itemName + "="), "");
273
+ let findValue = void 0;
274
+ for (const cookieItem of cookies) {
275
+ let item = cookieItem.trim();
276
+ let itemSplit = item.split("=");
277
+ let itemName = itemSplit[0];
278
+ itemSplit.splice(0, 1);
279
+ let itemValue = decodeURIComponent(itemSplit.join(""));
277
280
  if (itemName === cookieName) {
278
- return itemValue;
281
+ findValue = {
282
+ domain: globalThis.location.hostname,
283
+ expirationDate: null,
284
+ hostOnly: true,
285
+ httpOnly: false,
286
+ name: cookieName,
287
+ path: "/",
288
+ sameSite: "unspecified",
289
+ secure: true,
290
+ session: false,
291
+ value: itemValue,
292
+ };
293
+ break;
279
294
  }
280
- });
281
- if (findCookie) {
282
- return {
283
- domain: globalThis.location.hostname,
284
- expirationDate: null,
285
- hostOnly: true,
286
- httpOnly: false,
287
- name: cookieName,
288
- path: "/",
289
- sameSite: "unspecified",
290
- secure: true,
291
- session: false,
292
- value: findCookie,
293
- };
294
295
  }
296
+ return findValue;
295
297
  }
296
298
  /**
297
299
  * 获取多组Cookie
@@ -315,9 +317,11 @@ System.register('Utils', [], (function (exports) {
315
317
  details = utils.assign(details, paramDetails);
316
318
  let cookies = document.cookie.split(";");
317
319
  cookies.forEach((item) => {
318
- item = item.trimStart();
319
- let itemName = item.split("=")[0];
320
- let itemValue = item.replace(new RegExp("^" + itemName + "="), "");
320
+ item = item.trim();
321
+ let itemSplit = item.split("=");
322
+ let itemName = itemSplit[0];
323
+ itemSplit.splice(0, 1);
324
+ let itemValue = decodeURIComponent(itemSplit.join(""));
321
325
  let nameRegexp = details.name instanceof RegExp
322
326
  ? details.name
323
327
  : new RegExp("^" + details.name, "g");
@@ -364,9 +368,11 @@ System.register('Utils', [], (function (exports) {
364
368
  details = utils.assign(details, paramDetails);
365
369
  let cookies = document.cookie.split(";");
366
370
  cookies.forEach((item) => {
367
- item = item.trimStart();
368
- let itemName = item.split("=")[0];
369
- let itemValue = item.replace(new RegExp("^" + itemName + "="), "");
371
+ item = item.trim();
372
+ let itemSplit = item.split("=");
373
+ let itemName = itemSplit[0];
374
+ itemSplit.splice(0, 1);
375
+ let itemValue = decodeURIComponent(itemSplit.join(""));
370
376
  let nameRegexp = details.name instanceof RegExp
371
377
  ? details.name
372
378
  : new RegExp("^" + details.name, "g");