cookie-monster
Advanced tools
Comparing version 0.0.6 to 0.0.7
13
index.js
'use strict'; | ||
var exports = module.exports = function (doc) { | ||
exports = module.exports = function (doc) { | ||
if (!doc) doc = {}; | ||
@@ -13,6 +13,5 @@ if (typeof doc === 'string') doc = { cookie: doc }; | ||
var ps = cookiesSplat[i].split('='); | ||
var k = unescape(ps[0]); | ||
if (k === key) return unescape(ps[1]); | ||
var k = decodeURIComponent(ps[0]); | ||
if (k === key) return decodeURIComponent(ps[1]); | ||
} | ||
return undefined; | ||
}; | ||
@@ -22,3 +21,3 @@ | ||
if (!opts) opts = {}; | ||
var newCookie = escape(key) + '=' + escape(value); | ||
var newCookie = encodeURIComponent(key) + '=' + encodeURIComponent(value); | ||
@@ -30,3 +29,3 @@ if (opts.expires){ | ||
if (opts.path) { | ||
newCookie += '; path=' + escape(opts.path); | ||
newCookie += '; path=' + opts.path; | ||
} | ||
@@ -39,3 +38,3 @@ | ||
if (opts.secure) { | ||
newCookie += '; secure' | ||
newCookie += '; secure'; | ||
} | ||
@@ -42,0 +41,0 @@ |
{ | ||
"name": "cookie-monster", | ||
"description": "Browserify-compatible module to get and set cookies in the browser", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -18,2 +18,7 @@ var cookie = require('../index'); | ||
}); | ||
it('sets and gets cookie with `=` in value', function () { | ||
cookie.set('key', 'val=ue'); | ||
cookie.get('key').should.equal('val=ue'); | ||
}); | ||
}); |
6577
101