strict-cookie-parser
v3.2.0
Published
Parses cookie headers according to RFC 6265.
Downloads
167
Readme
Parses cookie headers according to RFC 6265, producing a Map.
For Connect (Express) middleware, see strict-cookie-middleware.
const strictCookieParser = require('strict-cookie-parser');
strictCookieParser.parseCookieHeader('hello=world; foo=bar ')
// Map { 'hello' => 'world', 'foo' => 'bar' }
strictCookieParser.parseCookieHeader('not a cookie')
// null
strictCookieParser.parseCookiePair('single=pair')
// { name: 'single', value: 'pair' }
strictCookieParser.isCookieName('foo')
// true
strictCookieParser.isCookieName('m=m')
// invalid - cookie names cannot contain =
// false
strictCookieParser.parseCookieValue('"foo"')
// 'foo'
strictCookieParser.parseCookieValue(' foo')
// invalid - unquoted cookie values cannot begin with a space
// null