Permalink
Browse files

Merge branch 'master' of github.com:amccollum/jar

  • Loading branch information...
2 parents 56043aa + d6ed2ba commit 7598e71731e11115b932805eca912b0baa091537 @amccollum committed Jan 12, 2012
Showing with 12 additions and 3 deletions.
  1. +7 −2 lib/jar.js
  2. +5 −1 src/jar.coffee
View
@@ -1,6 +1,6 @@
(function(jar) {
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) {
options = {};
}
@@ -31,7 +31,12 @@
if (Array.isArray(m)) {
if (m[1] === name) {
try {
- return JSON.parse(decodeURIComponent(m[2]));
+ decoded = decodeURIComponent(m[2]);
+ try {
+ return JSON.parse(decoded);
+ } catch (e) {
+ return decoded;
+ }
} catch (e) {
break;
}
View
@@ -26,7 +26,11 @@
if Array.isArray(m)
if m[1] == name
try
- return JSON.parse(decodeURIComponent(m[2]))
+ decoded = decodeURIComponent(m[2])
+ try
+ return JSON.parse(decoded)
+ catch e
+ return decoded
catch e
break

0 comments on commit 7598e71

Please sign in to comment.