The raw Set-Cookie header string (e.g., "sessionId=abc123; HttpOnly; Path=/").
An object with name and value properties, or null if
the string does not contain a valid name‑value pair.
This function extracts the first name=value pair before the first
semicolon (if any). It does not parse additional attributes
(e.g., HttpOnly, Secure, Path, Max-Age, Expires). Those are ignored.
The extraction algorithm:
;) – everything before it is the name=value part.=) to get name and value.null if the name is empty after trimming.const parsed = parseSetCookie('sessionId=abc123; HttpOnly; Path=/');
console.log(parsed); // { name: "sessionId", value: "abc123" }
Parses a raw
Set-Cookieheader string into its name and value.