Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/axios/lib/helpers/cookies.js
1126 views
1
'use strict';
2
3
var utils = require('./../utils');
4
5
module.exports = (
6
utils.isStandardBrowserEnv() ?
7
8
// Standard browser envs support document.cookie
9
(function standardBrowserEnv() {
10
return {
11
write: function write(name, value, expires, path, domain, secure) {
12
var cookie = [];
13
cookie.push(name + '=' + encodeURIComponent(value));
14
15
if (utils.isNumber(expires)) {
16
cookie.push('expires=' + new Date(expires).toGMTString());
17
}
18
19
if (utils.isString(path)) {
20
cookie.push('path=' + path);
21
}
22
23
if (utils.isString(domain)) {
24
cookie.push('domain=' + domain);
25
}
26
27
if (secure === true) {
28
cookie.push('secure');
29
}
30
31
document.cookie = cookie.join('; ');
32
},
33
34
read: function read(name) {
35
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36
return (match ? decodeURIComponent(match[3]) : null);
37
},
38
39
remove: function remove(name) {
40
this.write(name, '', Date.now() - 86400000);
41
}
42
};
43
})() :
44
45
// Non standard browser env (web workers, react-native) lack needed support.
46
(function nonStandardBrowserEnv() {
47
return {
48
write: function write() {},
49
read: function read() { return null; },
50
remove: function remove() {}
51
};
52
})()
53
);
54
55