coveo.analytics 2.33.0 → 2.33.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/dist/browser.mjs +32 -11
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +32 -11
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/version.d.ts +1 -1
- package/dist/esm/cookieutils.mjs +31 -10
- package/dist/library.cjs +60 -11452
- package/dist/library.es.js +32 -11
- package/dist/library.js +60 -11452
- package/dist/library.mjs +60 -11452
- package/dist/react-native.es.js +32 -11
- package/package.json +8 -8
- package/src/cookieutils.spec.ts +63 -8
- package/src/cookieutils.ts +32 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const libVersion = "2.33.
|
|
1
|
+
export declare const libVersion = "2.33.1";
|
package/dist/esm/cookieutils.mjs
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
class Cookie {
|
|
2
2
|
static set(name, value, expire) {
|
|
3
|
-
|
|
3
|
+
let expirationDate;
|
|
4
4
|
if (expire) {
|
|
5
5
|
expirationDate = new Date();
|
|
6
6
|
expirationDate.setTime(expirationDate.getTime() + expire);
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
if (host.indexOf('.') === -1) {
|
|
10
|
-
writeCookie(name, value, expirationDate);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
domainParts = host.split('.');
|
|
14
|
-
domain = domainParts[domainParts.length - 2] + '.' + domainParts[domainParts.length - 1];
|
|
15
|
-
writeCookie(name, value, expirationDate, domain);
|
|
16
|
-
}
|
|
8
|
+
writeCookie(name, value, expirationDate, getCookieDomain(window.location.hostname));
|
|
17
9
|
}
|
|
18
10
|
static get(name) {
|
|
19
11
|
var cookiePrefix = name + '=';
|
|
@@ -31,6 +23,35 @@ class Cookie {
|
|
|
31
23
|
Cookie.set(name, '', -1);
|
|
32
24
|
}
|
|
33
25
|
}
|
|
26
|
+
function getCookieDomain(host) {
|
|
27
|
+
if (host.indexOf('.') === -1) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const domainParts = host.split('.');
|
|
31
|
+
for (let domainLength = 2; domainLength <= domainParts.length; domainLength++) {
|
|
32
|
+
const domain = domainParts.slice(-domainLength).join('.');
|
|
33
|
+
if (supportsCookieDomain(domain)) {
|
|
34
|
+
return domain;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
function supportsCookieDomain(domain) {
|
|
40
|
+
const name = `__coveo_cookie_domain_test_${Math.random().toString(36).substring(2)}`;
|
|
41
|
+
try {
|
|
42
|
+
writeCookie(name, '1', undefined, domain);
|
|
43
|
+
return Cookie.get(name) === '1';
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
try {
|
|
50
|
+
writeCookie(name, '', new Date(0), domain);
|
|
51
|
+
}
|
|
52
|
+
catch { }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
34
55
|
function writeCookie(name, value, expirationDate, domain) {
|
|
35
56
|
document.cookie =
|
|
36
57
|
`${name}=${value}` +
|