项目作者: charmander

项目描述 :
A JavaScript cookie parsing module.
高级语言: JavaScript
项目地址: git://github.com/charmander/strict-cookie-parser.git
创建时间: 2015-03-27T03:57:31Z
项目社区:https://github.com/charmander/strict-cookie-parser

开源协议:ISC License

下载


Build status

Parses cookie headers according to RFC 6265, producing a Map.

For Connect (Express) middleware, see strict-cookie-middleware.

  1. import { parseCookieHeader } from 'strict-cookie-parser';
  2. parseCookieHeader('hello=world; foo=bar')
  3. // Map { 'hello' => 'world', 'foo' => 'bar' }
  4. parseCookieHeader('not a cookie')
  5. // null
  1. import {
  2. parseCookiePair,
  3. isCookieName,
  4. parseCookieValue,
  5. } from 'strict-cookie-parser';
  6. parseCookiePair('single=pair')
  7. // { name: 'single', value: 'pair' }
  8. isCookieName('foo')
  9. // true
  10. isCookieName('m=m')
  11. // invalid - cookie names cannot contain =
  12. // false
  13. parseCookieValue('"foo"')
  14. // 'foo'
  15. parseCookieValue(' foo')
  16. // invalid - unquoted cookie values cannot begin with a space
  17. // null