@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.
- package/dist/index.amd.js +31 -25
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +31 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +31 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +31 -25
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +31 -25
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +31 -25
- package/dist/index.umd.js.map +1 -1
- package/dist/src/UtilsGMCookie.d.ts +4 -15
- package/package.json +1 -1
- package/src/UtilsGMCookie.ts +36 -30
package/dist/index.esm.js
CHANGED
|
@@ -265,28 +265,30 @@ class UtilsGMCookie {
|
|
|
265
265
|
throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
|
|
266
266
|
}
|
|
267
267
|
let cookies = document.cookie.split(";");
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
let
|
|
271
|
-
let
|
|
268
|
+
let findValue = void 0;
|
|
269
|
+
for (const cookieItem of cookies) {
|
|
270
|
+
let item = cookieItem.trim();
|
|
271
|
+
let itemSplit = item.split("=");
|
|
272
|
+
let itemName = itemSplit[0];
|
|
273
|
+
itemSplit.splice(0, 1);
|
|
274
|
+
let itemValue = decodeURIComponent(itemSplit.join(""));
|
|
272
275
|
if (itemName === cookieName) {
|
|
273
|
-
|
|
276
|
+
findValue = {
|
|
277
|
+
domain: globalThis.location.hostname,
|
|
278
|
+
expirationDate: null,
|
|
279
|
+
hostOnly: true,
|
|
280
|
+
httpOnly: false,
|
|
281
|
+
name: cookieName,
|
|
282
|
+
path: "/",
|
|
283
|
+
sameSite: "unspecified",
|
|
284
|
+
secure: true,
|
|
285
|
+
session: false,
|
|
286
|
+
value: itemValue,
|
|
287
|
+
};
|
|
288
|
+
break;
|
|
274
289
|
}
|
|
275
|
-
});
|
|
276
|
-
if (findCookie) {
|
|
277
|
-
return {
|
|
278
|
-
domain: globalThis.location.hostname,
|
|
279
|
-
expirationDate: null,
|
|
280
|
-
hostOnly: true,
|
|
281
|
-
httpOnly: false,
|
|
282
|
-
name: cookieName,
|
|
283
|
-
path: "/",
|
|
284
|
-
sameSite: "unspecified",
|
|
285
|
-
secure: true,
|
|
286
|
-
session: false,
|
|
287
|
-
value: findCookie,
|
|
288
|
-
};
|
|
289
290
|
}
|
|
291
|
+
return findValue;
|
|
290
292
|
}
|
|
291
293
|
/**
|
|
292
294
|
* 获取多组Cookie
|
|
@@ -310,9 +312,11 @@ class UtilsGMCookie {
|
|
|
310
312
|
details = utils.assign(details, paramDetails);
|
|
311
313
|
let cookies = document.cookie.split(";");
|
|
312
314
|
cookies.forEach((item) => {
|
|
313
|
-
item = item.
|
|
314
|
-
let
|
|
315
|
-
let
|
|
315
|
+
item = item.trim();
|
|
316
|
+
let itemSplit = item.split("=");
|
|
317
|
+
let itemName = itemSplit[0];
|
|
318
|
+
itemSplit.splice(0, 1);
|
|
319
|
+
let itemValue = decodeURIComponent(itemSplit.join(""));
|
|
316
320
|
let nameRegexp = details.name instanceof RegExp
|
|
317
321
|
? details.name
|
|
318
322
|
: new RegExp("^" + details.name, "g");
|
|
@@ -359,9 +363,11 @@ class UtilsGMCookie {
|
|
|
359
363
|
details = utils.assign(details, paramDetails);
|
|
360
364
|
let cookies = document.cookie.split(";");
|
|
361
365
|
cookies.forEach((item) => {
|
|
362
|
-
item = item.
|
|
363
|
-
let
|
|
364
|
-
let
|
|
366
|
+
item = item.trim();
|
|
367
|
+
let itemSplit = item.split("=");
|
|
368
|
+
let itemName = itemSplit[0];
|
|
369
|
+
itemSplit.splice(0, 1);
|
|
370
|
+
let itemValue = decodeURIComponent(itemSplit.join(""));
|
|
365
371
|
let nameRegexp = details.name instanceof RegExp
|
|
366
372
|
? details.name
|
|
367
373
|
: new RegExp("^" + details.name, "g");
|