UNPKG

@shopify/hydrogen-react

Version:

React components, hooks, and utilities for creating custom Shopify storefronts

28 lines (27 loc) 801 B
var g = /* @__PURE__ */ new Set([ "domain", "path", "max-age", "expires", "samesite", "secure", "httponly" ]); function u(a) { let r = {}, e, t, n = 0, m = a.split(/;\s*/g), s, i; for (; n < m.length; n++) if (t = m[n], e = t.indexOf("="), ~e) { if (s = t.substring(0, e++).trim(), i = t.substring(e).trim(), i[0] === '"' && (i = i.substring(1, i.length - 1)), ~i.indexOf("%")) try { i = decodeURIComponent(i); } catch (f) { } g.has(t = s.toLowerCase()) ? t === "expires" ? r.expires = new Date(i) : t === "max-age" ? r.maxage = +i : r[t] = i : r[s] = i; } else (s = t.trim().toLowerCase()) && (s === "httponly" || s === "secure") && (r[s] = true); return r; } export { u as parse }; //# sourceMappingURL=index.mjs.map