mirror of
https://codeberg.org/tacerus/teddit.git
synced 2025-01-09 12:52:32 +01:00
21 lines
427 B
JavaScript
21 lines
427 B
JavaScript
'use strict'
|
|
|
|
var tough = require('tough-cookie')
|
|
|
|
var Cookie = tough.Cookie
|
|
var 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, {loose: true})
|
|
}
|
|
|
|
exports.jar = function (store) {
|
|
return new CookieJar(store, {looseMode: true})
|
|
}
|