@skrillex1224/playwright-toolkit 2.1.185 → 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/index.cjs CHANGED
@@ -1006,6 +1006,20 @@ var normalizeCookieSameSite = (value) => {
1006
1006
  return "";
1007
1007
  }
1008
1008
  };
1009
+ var normalizeCookieExpires = (raw = {}) => {
1010
+ const source = raw && typeof raw === "object" ? raw : {};
1011
+ const session = Boolean(source.session);
1012
+ if (session) return null;
1013
+ const expiresCandidate = Number(source.expires);
1014
+ if (Number.isFinite(expiresCandidate) && expiresCandidate > 0) {
1015
+ return expiresCandidate;
1016
+ }
1017
+ const expirationDateCandidate = Number(source.expirationDate);
1018
+ if (Number.isFinite(expirationDateCandidate) && expirationDateCandidate > 0) {
1019
+ return expirationDateCandidate;
1020
+ }
1021
+ return null;
1022
+ };
1009
1023
  var normalizeCookies = (value) => {
1010
1024
  if (!Array.isArray(value)) return [];
1011
1025
  return value.map((item) => {
@@ -1014,15 +1028,28 @@ var normalizeCookies = (value) => {
1014
1028
  const cookieValue = String(raw.value ?? "").trim();
1015
1029
  if (!name || !cookieValue || cookieValue === "<nil>") return null;
1016
1030
  const domain = String(raw.domain || "").trim();
1031
+ const url = normalizeHttpUrl(raw.url);
1017
1032
  const path2 = String(raw.path || "").trim() || "/";
1018
1033
  const sameSite = normalizeCookieSameSite(raw.sameSite);
1019
- return {
1020
- ...raw,
1034
+ const expires = normalizeCookieExpires(raw);
1035
+ const secure = Boolean(raw.secure);
1036
+ const httpOnly = Boolean(raw.httpOnly);
1037
+ const normalized = {
1021
1038
  name,
1022
1039
  value: cookieValue,
1023
- domain,
1024
1040
  path: path2,
1025
- ...sameSite ? { sameSite } : {}
1041
+ ...domain ? { domain } : {},
1042
+ ...!domain && url ? { url } : {},
1043
+ ...sameSite ? { sameSite } : {},
1044
+ ...secure ? { secure: true } : {},
1045
+ ...httpOnly ? { httpOnly: true } : {},
1046
+ ...expires !== null ? { expires } : {}
1047
+ };
1048
+ if (!normalized.domain && !normalized.url) {
1049
+ return null;
1050
+ }
1051
+ return {
1052
+ ...normalized
1026
1053
  };
1027
1054
  }).filter(Boolean);
1028
1055
  };