js-cookie 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/js.cookie.js +7 -9
- package/dist/js.cookie.min.js +2 -2
- package/dist/js.cookie.min.mjs +2 -2
- package/dist/js.cookie.mjs +7 -9
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="https://cloud.githubusercontent.com/assets/835857/14581711/ba623018-0436-11e6-8fce-d2ccd4d379c9.gif">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
# JavaScript Cookie [](https://travis-ci.com/js-cookie/js-cookie) [](https://www.browserstack.com/automate/public-build/b3VDaHAxVDg0NDdCRmtUOWg0SlQzK2NsRVhWTjlDQS9qdGJoak1GMzJiVT0tLVhwZHNvdGRoY284YVRrRnI3eU1JTnc9PQ==--5e88ffb3ca116001d7ef2cfb97a4128ac31174c2) [](https://standardjs.com) [](https://codeclimate.com/github/js-cookie/js-cookie) [](https://www.npmjs.com/package/js-cookie) [](https://travis-ci.com/js-cookie/js-cookie) [](https://www.browserstack.com/automate/public-build/b3VDaHAxVDg0NDdCRmtUOWg0SlQzK2NsRVhWTjlDQS9qdGJoak1GMzJiVT0tLVhwZHNvdGRoY284YVRrRnI3eU1JTnc9PQ==--5e88ffb3ca116001d7ef2cfb97a4128ac31174c2) [](https://standardjs.com) [](https://codeclimate.com/github/js-cookie/js-cookie) [](https://www.npmjs.com/package/js-cookie) [](https://www.npmjs.com/package/js-cookie) [](https://www.jsdelivr.com/package/npm/js-cookie)
|
|
6
6
|
|
|
7
7
|
A simple, lightweight JavaScript API for handling cookies
|
|
8
8
|
|
package/dist/js.cookie.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
1
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
2
2
|
;
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
/* eslint-disable no-var */
|
|
26
26
|
var defaultConverter = {
|
|
27
27
|
read: function (value) {
|
|
28
|
+
if (value[0] === '"') {
|
|
29
|
+
value = value.slice(1, -1);
|
|
30
|
+
}
|
|
28
31
|
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
29
32
|
},
|
|
30
33
|
write: function (value) {
|
|
@@ -57,8 +60,6 @@
|
|
|
57
60
|
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
58
61
|
.replace(/[()]/g, escape);
|
|
59
62
|
|
|
60
|
-
value = converter.write(value, key);
|
|
61
|
-
|
|
62
63
|
var stringifiedAttributes = '';
|
|
63
64
|
for (var attributeName in attributes) {
|
|
64
65
|
if (!attributes[attributeName]) {
|
|
@@ -81,7 +82,8 @@
|
|
|
81
82
|
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
return (document.cookie =
|
|
85
|
+
return (document.cookie =
|
|
86
|
+
key + '=' + converter.write(value, key) + stringifiedAttributes)
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
function get (key) {
|
|
@@ -97,12 +99,8 @@
|
|
|
97
99
|
var parts = cookies[i].split('=');
|
|
98
100
|
var value = parts.slice(1).join('=');
|
|
99
101
|
|
|
100
|
-
if (value[0] === '"') {
|
|
101
|
-
value = value.slice(1, -1);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
102
|
try {
|
|
105
|
-
var foundKey =
|
|
103
|
+
var foundKey = decodeURIComponent(parts[0]);
|
|
106
104
|
jar[foundKey] = converter.read(value, foundKey);
|
|
107
105
|
|
|
108
106
|
if (key === foundKey) {
|
package/dist/js.cookie.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,
|
|
1
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}));
|
package/dist/js.cookie.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
2
|
-
function e(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}var t=
|
|
1
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
2
|
+
function e(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}var t=function t(r,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=e({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+r.write(o,t)+c}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],n={},o=0;o<t.length;o++){var i=t[o].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(n[u]=r.read(c,u),e===u)break}catch(e){}}return e?n[e]:n}},remove:function(t,r){o(t,"",e({},r,{expires:-1}))},withAttributes:function(r){return t(this.converter,e({},this.attributes,r))},withConverter:function(r){return t(e({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(r)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});export default t;
|
package/dist/js.cookie.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! js-cookie v3.0.
|
|
1
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
2
2
|
/* eslint-disable no-var */
|
|
3
3
|
function assign (target) {
|
|
4
4
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -14,6 +14,9 @@ function assign (target) {
|
|
|
14
14
|
/* eslint-disable no-var */
|
|
15
15
|
var defaultConverter = {
|
|
16
16
|
read: function (value) {
|
|
17
|
+
if (value[0] === '"') {
|
|
18
|
+
value = value.slice(1, -1);
|
|
19
|
+
}
|
|
17
20
|
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
18
21
|
},
|
|
19
22
|
write: function (value) {
|
|
@@ -46,8 +49,6 @@ function init (converter, defaultAttributes) {
|
|
|
46
49
|
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
47
50
|
.replace(/[()]/g, escape);
|
|
48
51
|
|
|
49
|
-
value = converter.write(value, key);
|
|
50
|
-
|
|
51
52
|
var stringifiedAttributes = '';
|
|
52
53
|
for (var attributeName in attributes) {
|
|
53
54
|
if (!attributes[attributeName]) {
|
|
@@ -70,7 +71,8 @@ function init (converter, defaultAttributes) {
|
|
|
70
71
|
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
return (document.cookie =
|
|
74
|
+
return (document.cookie =
|
|
75
|
+
key + '=' + converter.write(value, key) + stringifiedAttributes)
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
function get (key) {
|
|
@@ -86,12 +88,8 @@ function init (converter, defaultAttributes) {
|
|
|
86
88
|
var parts = cookies[i].split('=');
|
|
87
89
|
var value = parts.slice(1).join('=');
|
|
88
90
|
|
|
89
|
-
if (value[0] === '"') {
|
|
90
|
-
value = value.slice(1, -1);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
91
|
try {
|
|
94
|
-
var foundKey =
|
|
92
|
+
var foundKey = decodeURIComponent(parts[0]);
|
|
95
93
|
jar[foundKey] = converter.read(value, foundKey);
|
|
96
94
|
|
|
97
95
|
if (key === foundKey) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-cookie",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "A simple, lightweight JavaScript API for handling cookies",
|
|
5
5
|
"browser": "dist/js.cookie.js",
|
|
6
6
|
"module": "dist/js.cookie.mjs",
|
|
7
7
|
"unpkg": "dist/js.cookie.min.js",
|
|
8
8
|
"jsdelivr": "dist/js.cookie.min.js",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/js.cookie.mjs",
|
|
12
|
+
"require": "./dist/js.cookie.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
12
15
|
},
|
|
13
16
|
"directories": {
|
|
14
17
|
"test": "test"
|