Fix domain parsing (#75)

Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
GermeyandAceDataCloud authored and GitHub committed 2024-07-07 15:39:12 +00:00
1 parent f33237b5aa
commit ae0f5e90a9
2 files changed
+13 -3

No files matched your search

@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix for domain parsing",
"packageName": "@acedatacloud/nexior",
"email": "office@acedata.cloud",
"dependentChangeType": "patch"
}
+6 -3
View File
@@ -7,19 +7,22 @@ import { IToken } from '@/models';
import psl from 'psl';
export const getDomain = (host: string = window.location.hostname) => {
if (host === 'localhost') {
return host;
}
const parsed = psl.parse(host);
if (parsed.error) {
return host;
}
if (!parsed.listed) {
return host;
}
if (parsed.domain === host) {
return host;
}
return '.' + parsed.domain;
};
// @ts-ignore
window.getDomain = getDomain;
export const initializeCookies = async () => {
// parse the query string and set to cookies
const query = new URLSearchParams(window.location.search);