-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathjs.cookie.js
More file actions
88 lines (88 loc) · 2.55 KB
/
js.cookie.js
File metadata and controls
88 lines (88 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*! js-cookie v3.0.1 | MIT */
!((e, t) => {
"object" === typeof exports && "undefined" !== typeof module
? (module.exports = t())
: "function" === typeof define && define.amd
? define(t)
: ((e = e || self),
(() => {
var n = e.Cookies,
o = (e.Cookies = t())
o.noConflict = () => ((e.Cookies = n), o)
})())
})(this, () => {
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: (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: (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: (e) => (
'"' === e[0] && (e = e.slice(1, -1)),
e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
),
write: (e) =>
encodeURIComponent(e).replace(
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
decodeURIComponent,
),
},
{ path: "/" },
)
})