/** * @source https://github.com/jshttp/cookie * @author blakeembrey * @license MIT */ /** * This is a workaround to support ESM-only environments, until `cookie` ships ESM builds. * @see https://github.com/jshttp/cookie/issues/211 */ /** * RegExp to match cookie-name in RFC 6265 sec 4.1.1 * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2 * which has been replaced by the token definition in RFC 7230 appendix B. * * cookie-name = token * token = 1*tchar * tchar = "!" / "#" / "$" / "%" / "&" / "'" / * "*" / "+" / "-" / "." / "^" / "_" / * "`" / "|" / "~" / DIGIT / ALPHA */ const cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/ /** * RegExp to match cookie-value in RFC 6265 sec 4.1.1 * * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE ) * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E * ; US-ASCII characters excluding CTLs, * ; whitespace DQUOTE, comma, semicolon, * ; and backslash */ const cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/ /** * RegExp to match domain-value in RFC 6265 sec 4.1.1 * * domain-value = * ; defined in [RFC1034], Section 3.5, as * ; enhanced by [RFC1123], Section 2.1 * =