Socket
Socket
Sign inDemoInstall

tiny-cookie

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

2

bower.json
{
"name": "tiny-cookie",
"version": "1.0.0",
"version": "1.0.1",
"main": "tiny-cookie.js",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/Alex1990/tiny-cookie",

{
"name": "tiny-cookie",
"version": "1.0.0",
"version": "1.0.1",
"description": "A tiny cookie manipulation plugin",

@@ -5,0 +5,0 @@ "main": "tiny-cookie.js",

@@ -43,3 +43,3 @@ # tiny-cookie

Set a cookie with encoding the value, using `encodeURIComponent`. The `options` parameter is an object. And its property can be a valid cookie option, such as `path`(default: root path `/`), `domain`, `expires`/`max-age` or `secure`. For example, you can set the expiration:
Set a cookie with encoding the value, using `encodeURIComponent`. The `options` parameter is an object. And its property can be a valid cookie option, such as `path`(default: root path `/`), `domain`, `expires`/`max-age` or `secure` (Note: the `secure` flag will be set if it is an truthy value, such as `true`, or it will be not set). For example, you can set the expiration:

@@ -46,0 +46,0 @@ ```js

@@ -145,2 +145,12 @@ describe('Cookie()', function() {

});
it('should set secure when option is true', function() {
Cookie.set('someKey', 'someValue', { secure: true });
expect(Cookie.get('someKey')).toBe(null);
});
it('should not set secure when option is false', function() {
Cookie.set('someKey', 'someValue', { secure: false });
expect(Cookie.get('someKey')).toBe('someValue');
});
});

@@ -147,0 +157,0 @@

@@ -112,2 +112,10 @@ /*!

if (p === 'secure') {
if (opts[p]) {
res += ';' + p;
}
continue;
}
res += ';' + p + '=' + opts[p];

@@ -114,0 +122,0 @@ }

@@ -1,1 +0,1 @@

!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.Cookie=t()}(this,function(){"use strict";function e(t,n,o){return void 0===n?e.get(t):void(null===n?e.remove(t):e.set(t,n,o))}function t(e){return e.replace(/[.*+?^$|[\](){}\\-]/g,"\\$&")}function n(e){var t="";for(var n in e)if(e.hasOwnProperty(n)){if("expires"===n){var r=e[n];"object"!=typeof r&&(r+="number"==typeof r?"D":"",r=o(r)),e[n]=r.toUTCString()}t+=";"+n+"="+e[n]}return e.hasOwnProperty("path")||(t+=";path=/"),t}function o(e){var t=new Date,n=e.charAt(e.length-1),o=parseInt(e,10);switch(n){case"Y":t.setFullYear(t.getFullYear()+o);break;case"M":t.setMonth(t.getMonth()+o);break;case"D":t.setDate(t.getDate()+o);break;case"h":t.setHours(t.getHours()+o);break;case"m":t.setMinutes(t.getMinutes()+o);break;case"s":t.setSeconds(t.getSeconds()+o);break;default:t=new Date(e)}return t}return e.enabled=function(){var t,n="__test_key";return document.cookie=n+"=1",t=!!document.cookie,t&&e.remove(n),t},e.get=function(e,n){if("string"!=typeof e||!e)return null;e="(?:^|; )"+t(e)+"(?:=([^;]*?))?(?:;|$)";var o=new RegExp(e),r=o.exec(document.cookie);return null!==r?n?r[1]:decodeURIComponent(r[1]):null},e.getRaw=function(t){return e.get(t,!0)},e.set=function(e,t,o,r){o!==!0&&(r=o,o=!1),r=n(r?r:{});var u=e+"="+(o?t:encodeURIComponent(t))+r;document.cookie=u},e.setRaw=function(t,n,o){e.set(t,n,!0,o)},e.remove=function(t){e.set(t,"a",{expires:new Date})},e});
!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.Cookie=t()}(this,function(){"use strict";function e(t,n,o){return void 0===n?e.get(t):void(null===n?e.remove(t):e.set(t,n,o))}function t(e){return e.replace(/[.*+?^$|[\](){}\\-]/g,"\\$&")}function n(e){var t="";for(var n in e)if(e.hasOwnProperty(n)){if("expires"===n){var r=e[n];"object"!=typeof r&&(r+="number"==typeof r?"D":"",r=o(r)),e[n]=r.toUTCString()}if("secure"===n){if(!e[n])continue;t+=";"+n}t+=";"+n+"="+e[n]}return e.hasOwnProperty("path")||(t+=";path=/"),t}function o(e){var t=new Date,n=e.charAt(e.length-1),o=parseInt(e,10);switch(n){case"Y":t.setFullYear(t.getFullYear()+o);break;case"M":t.setMonth(t.getMonth()+o);break;case"D":t.setDate(t.getDate()+o);break;case"h":t.setHours(t.getHours()+o);break;case"m":t.setMinutes(t.getMinutes()+o);break;case"s":t.setSeconds(t.getSeconds()+o);break;default:t=new Date(e)}return t}return e.enabled=function(){var t,n="__test_key";return document.cookie=n+"=1",t=!!document.cookie,t&&e.remove(n),t},e.get=function(e,n){if("string"!=typeof e||!e)return null;e="(?:^|; )"+t(e)+"(?:=([^;]*?))?(?:;|$)";var o=new RegExp(e),r=o.exec(document.cookie);return null!==r?n?r[1]:decodeURIComponent(r[1]):null},e.getRaw=function(t){return e.get(t,!0)},e.set=function(e,t,o,r){o!==!0&&(r=o,o=!1),r=n(r?r:{});var u=e+"="+(o?t:encodeURIComponent(t))+r;document.cookie=u},e.setRaw=function(t,n,o){e.set(t,n,!0,o)},e.remove=function(t){e.set(t,"a",{expires:new Date})},e});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc