diff --git a/cookies.js b/cookies.js index 8a7e51f..6a9ec96 100644 --- a/cookies.js +++ b/cookies.js @@ -1,19 +1,19 @@ /*! - * Cookies.js - 0.1.5 - * Saturday, May 06 2012 @ 5:57 PM EST + * Cookies.js - 0.1.6 + * Saturday, May 06 2012 @ 9:56 PM EST * * Copyright (c) 2012, Scott Hamper * Licensed under the MIT license, * http://www.opensource.org/licenses/MIT */ (function (document, undefined) { - + 'use strict'; + var Cookies = function () { - var args = Array.prototype.slice.call(arguments); - if (args.length === 1) { - return Cookies.get(args[0]); + if (arguments.length === 1) { + return Cookies.get(arguments[0]); } else { - return Cookies.set(args[0], args[1], args[2]); + return Cookies.set(arguments[0], arguments[1], arguments[2]); } }; @@ -37,11 +37,7 @@ secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure }; - // Expire the cookie if value is `undefined` - if (value === undefined) { - options.expires = -1; - value = ''; - } + if (value === undefined) { options.expires = -1; } switch (typeof options.expires) { // If a number is passed in, make it work like 'max-age' diff --git a/cookies.min.js b/cookies.min.js index 37ea2f1..b8a9766 100644 --- a/cookies.min.js +++ b/cookies.min.js @@ -1,4 +1,4 @@ -/*! Cookies.js - 0.1.5; Copyright (c) 2012, Scott Hamper; http://www.opensource.org/licenses/MIT */ -(function(f,e){var b=function(){var c=Array.prototype.slice.call(arguments);return 1===c.length?b.get(c[0]):b.set(c[0],c[1],c[2])};b.get=function(c){f.cookie!==b._cacheString&&b._populateCache();return b._cache[c]};b.defaults={path:"/"};b.set=function(c,d,a){a={path:a&&a.path||b.defaults.path,domain:a&&a.domain||b.defaults.domain,expires:a&&a.expires||b.defaults.expires,secure:a&&a.secure!==e?a.secure:b.defaults.secure};d===e&&(a.expires=-1,d="");switch(typeof a.expires){case "number":a.expires=new Date((new Date).getTime()+ +/*! Cookies.js - 0.1.6; Copyright (c) 2012, Scott Hamper; http://www.opensource.org/licenses/MIT */ +(function(f,e){var b=function(){return 1===arguments.length?b.get(arguments[0]):b.set(arguments[0],arguments[1],arguments[2])};b.get=function(c){f.cookie!==b._cacheString&&b._populateCache();return b._cache[c]};b.defaults={path:"/"};b.set=function(c,d,a){a={path:a&&a.path||b.defaults.path,domain:a&&a.domain||b.defaults.domain,expires:a&&a.expires||b.defaults.expires,secure:a&&a.secure!==e?a.secure:b.defaults.secure};d===e&&(a.expires=-1);switch(typeof a.expires){case "number":a.expires=new Date((new Date).getTime()+ 1E3*a.expires);break;case "string":a.expires=new Date(a.expires)}c=encodeURIComponent(c)+"="+encodeURIComponent(JSON.stringify(d));c+=a.path?";path="+a.path:"";c+=a.domain?";domain="+a.domain:"";c+=a.expires?";expires="+a.expires.toGMTString():"";c+=a.secure?";secure":"";f.cookie=c;return b};b.expire=function(c,d){return b.set(c,e,d)};b._populateCache=function(){b._cache={};b._cacheString=f.cookie;for(var c=b._cacheString.split("; "),d=0;d