vendor/assets/javascripts/js.cookie.js in js_cookie_rails-2.1.3 vs vendor/assets/javascripts/js.cookie.js in js_cookie_rails-2.1.4
- old
+ new
@@ -1,7 +1,7 @@
/*!
- * JavaScript Cookie v2.1.3
+ * JavaScript Cookie v2.1.4
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
@@ -54,10 +54,13 @@
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
+ // We're using "expires" because "max-age" is not supported by IE
+ attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
+
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
@@ -72,16 +75,22 @@
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);
- return (document.cookie = [
- key, '=', value,
- attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
- attributes.path ? '; path=' + attributes.path : '',
- attributes.domain ? '; domain=' + attributes.domain : '',
- attributes.secure ? '; secure' : ''
- ].join(''));
+ var stringifiedAttributes = '';
+
+ for (var attributeName in attributes) {
+ if (!attributes[attributeName]) {
+ continue;
+ }
+ stringifiedAttributes += '; ' + attributeName;
+ if (attributes[attributeName] === true) {
+ continue;
+ }
+ stringifiedAttributes += '=' + attributes[attributeName];
+ }
+ return (document.cookie = key + '=' + value + stringifiedAttributes);
}
// Read
if (!key) {