@skrillex1224/playwright-toolkit 2.1.184 → 2.1.186

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/browser.js CHANGED
@@ -1370,6 +1370,36 @@ var normalizeAuth = (value) => {
1370
1370
  return acc;
1371
1371
  }, {});
1372
1372
  };
1373
+ var normalizeCookieSameSite = (value) => {
1374
+ const raw = String(value || "").trim().toLowerCase();
1375
+ if (!raw) return "";
1376
+ switch (raw) {
1377
+ case "strict":
1378
+ return "Strict";
1379
+ case "lax":
1380
+ return "Lax";
1381
+ case "none":
1382
+ case "no_restriction":
1383
+ return "None";
1384
+ case "unspecified":
1385
+ default:
1386
+ return "";
1387
+ }
1388
+ };
1389
+ var normalizeCookieExpires = (raw = {}) => {
1390
+ const source = raw && typeof raw === "object" ? raw : {};
1391
+ const session = Boolean(source.session);
1392
+ if (session) return null;
1393
+ const expiresCandidate = Number(source.expires);
1394
+ if (Number.isFinite(expiresCandidate) && expiresCandidate > 0) {
1395
+ return expiresCandidate;
1396
+ }
1397
+ const expirationDateCandidate = Number(source.expirationDate);
1398
+ if (Number.isFinite(expirationDateCandidate) && expirationDateCandidate > 0) {
1399
+ return expirationDateCandidate;
1400
+ }
1401
+ return null;
1402
+ };
1373
1403
  var normalizeCookies = (value) => {
1374
1404
  if (!Array.isArray(value)) return [];
1375
1405
  return value.map((item) => {
@@ -1379,15 +1409,28 @@ var normalizeCookies = (value) => {
1379
1409
  const cookieValue = String((_a = raw.value) != null ? _a : "").trim();
1380
1410
  if (!name || !cookieValue || cookieValue === "<nil>") return null;
1381
1411
  const domain = String(raw.domain || "").trim();
1412
+ const url = normalizeHttpUrl(raw.url);
1382
1413
  const path = String(raw.path || "").trim() || "/";
1383
- const sameSiteRaw = String(raw.sameSite || "").trim();
1384
- return {
1385
- ...raw,
1414
+ const sameSite = normalizeCookieSameSite(raw.sameSite);
1415
+ const expires = normalizeCookieExpires(raw);
1416
+ const secure = Boolean(raw.secure);
1417
+ const httpOnly = Boolean(raw.httpOnly);
1418
+ const normalized = {
1386
1419
  name,
1387
1420
  value: cookieValue,
1388
- domain,
1389
1421
  path,
1390
- ...sameSiteRaw ? { sameSite: sameSiteRaw } : {}
1422
+ ...domain ? { domain } : {},
1423
+ ...!domain && url ? { url } : {},
1424
+ ...sameSite ? { sameSite } : {},
1425
+ ...secure ? { secure: true } : {},
1426
+ ...httpOnly ? { httpOnly: true } : {},
1427
+ ...expires !== null ? { expires } : {}
1428
+ };
1429
+ if (!normalized.domain && !normalized.url) {
1430
+ return null;
1431
+ }
1432
+ return {
1433
+ ...normalized
1391
1434
  };
1392
1435
  }).filter(Boolean);
1393
1436
  };