| 1 | 'use strict'; |
| 2 | var toughCookie = require('tough-cookie'); |
| 3 | |
| 4 | module.exports = function (str) { |
| 5 | if (typeof str !== 'string') { |
| 6 | throw new TypeError('Expected a string'); |
| 7 | } |
| 8 | |
| 9 | var cookie = toughCookie.parse(str); |
| 10 | |
| 11 | return { |
| 12 | // the touch-cookie output is slightly |
| 13 | // different from what PhantomJS accepts |
| 14 | name: cookie.key, |
| 15 | value: cookie.value, |
| 16 | domain: cookie.domain, |
| 17 | path: cookie.path, |
| 18 | httponly: cookie.httpOnly, |
| 19 | secure: cookie.secure, |
| 20 | expires: cookie.expires |
| 21 | }; |
| 22 | }; |