Fix domain parsing (#75)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
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"
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user