Skip to content

Commit

Permalink
Merge pull request request#744 from lalitkapoor/should-use-cookie-parse
Browse files Browse the repository at this point in the history
Use Cookie.parse
  • Loading branch information
mikeal committed Jan 9, 2014
2 parents 6122041 + 41e20a4 commit 2d7072d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -153,5 +153,5 @@ request.jar = function () {
request.cookie = 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 new Cookie(str)
return Cookie.parse(str)
}
19 changes: 19 additions & 0 deletions tests/test-cookies.js
@@ -0,0 +1,19 @@
try {
require('tough-cookie')
} catch (e) {
console.error('tough-cookie must be installed to run this test.')
console.error('skipping this test. please install tough-cookie and run again if you need to test this feature.')
process.exit(0)
}

var assert = require('assert')
, request = require('../index')


function simpleCookieCreationTest() {
var cookie = request.cookie('foo=bar')
assert(cookie.key === 'foo')
assert(cookie.value === 'bar')
}

simpleCookieCreationTest()

0 comments on commit 2d7072d

Please sign in to comment.