Skip to content

Commit

Permalink
Merge branch 'master' of github.com:amccollum/jar
Browse files Browse the repository at this point in the history
  • Loading branch information
amccollum committed Jan 12, 2012
2 parents 56043aa + d6ed2ba commit 7598e71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/jar.js
@@ -1,6 +1,6 @@
(function(jar) { (function(jar) {
return jar.cookie = function(name, value, options) { return jar.cookie = function(name, value, options) {
var cookie, date, domain, expires, m, path, secure, _i, _len, _ref; var cookie, date, decoded, domain, expires, m, path, secure, _i, _len, _ref;
if (options == null) { if (options == null) {
options = {}; options = {};
} }
Expand Down Expand Up @@ -31,7 +31,12 @@
if (Array.isArray(m)) { if (Array.isArray(m)) {
if (m[1] === name) { if (m[1] === name) {
try { try {
return JSON.parse(decodeURIComponent(m[2])); decoded = decodeURIComponent(m[2]);
try {
return JSON.parse(decoded);
} catch (e) {
return decoded;
}
} catch (e) { } catch (e) {
break; break;
} }
Expand Down
6 changes: 5 additions & 1 deletion src/jar.coffee
Expand Up @@ -26,7 +26,11 @@
if Array.isArray(m) if Array.isArray(m)
if m[1] == name if m[1] == name
try try
return JSON.parse(decodeURIComponent(m[2])) decoded = decodeURIComponent(m[2])
try
return JSON.parse(decoded)
catch e
return decoded
catch e catch e
break break


Expand Down

0 comments on commit 7598e71

Please sign in to comment.