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