Skip to content

Commit

Permalink
v8.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Dec 7, 2022
1 parent bab0d2b commit f496f41
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gleap",
"version": "8.4.3",
"version": "8.4.4",
"main": "build/index.js",
"scripts": {
"start": "webpack serve",
Expand Down
1 change: 1 addition & 0 deletions published/8.4.4/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion published/latest/index.js

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions src/GleapHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ export const truncateString = (str, num) => {
}
}

const removeSubDomain = (v) => {
try {
var parts = v.split('.');
var is2ndLevelDomain = false;
const secondLevel = parts[parts.length - 2];
if (secondLevel === "co" || secondLevel === "com" || secondLevel === "gv" || secondLevel === "ac" || secondLevel === "edu" || secondLevel === "gov" || secondLevel === "mil" || secondLevel === "net" || secondLevel === "org") {
is2ndLevelDomain = true;
}
parts = parts.slice(is2ndLevelDomain ? -3 : -2);
return parts.join('.');
} catch (exp) { }
return v;
}

export const loadFromGleapCache = (key) => {
try {
const cachedData = localStorage.getItem(`gleap-widget-${key}`);
Expand Down Expand Up @@ -110,7 +124,7 @@ export const setGleapCookie = (name, value, days) => {
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
const host = window.location.host.split(":")[0];
const host = removeSubDomain(window.location.host.split(":")[0]);
document.cookie = name + "=" + (value || "") + expires + "; path=/; domain=" + host;
} catch (exp) { }
}
Expand All @@ -130,7 +144,7 @@ export const getGleapCookie = (name) => {

export const eraseGleapCookie = (name) => {
try {
const host = window.location.host.split(":")[0];
const host = removeSubDomain(window.location.host.split(":")[0]);
document.cookie = name + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Domain=' + host;
} catch (exp) { }
}
Expand Down

0 comments on commit f496f41

Please sign in to comment.