Sha256: 2cbb36d465eac68f9253fa9733ac9f301ed7079e8b4f36d1ea1a3b6acb3e83fc

Contents?: true

Size: 935 Bytes

Versions: 78

Compression:

Stored size: 935 Bytes

Contents

'use strict'

var tough = require('tough-cookie')

var Cookie = tough.Cookie
  , CookieJar = tough.CookieJar


exports.parse = function(str) {
  if (str && str.uri) {
    str = str.uri
  }
  if (typeof str !== 'string') {
    throw new Error('The cookie function only accepts STRING as param')
  }
  return Cookie.parse(str)
}

// Adapt the sometimes-Async api of tough.CookieJar to our requirements
function RequestJar(store) {
  var self = this
  self._jar = new CookieJar(store)
}
RequestJar.prototype.setCookie = function(cookieOrStr, uri, options) {
  var self = this
  return self._jar.setCookieSync(cookieOrStr, uri, options || {})
}
RequestJar.prototype.getCookieString = function(uri) {
  var self = this
  return self._jar.getCookieStringSync(uri)
}
RequestJar.prototype.getCookies = function(uri) {
  var self = this
  return self._jar.getCookiesSync(uri)
}

exports.jar = function(store) {
  return new RequestJar(store)
}

Version data entries

78 entries across 75 versions & 4 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/request/lib/cookies.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/request/lib/cookies.js