Skip to content

Commit

Permalink
Fix domain parsing (#75)
Browse files Browse the repository at this point in the history
Co-authored-by: AceDataCloud <office@acedata.cloud>
  • Loading branch information
Germey and AceDataCloud authored Jul 7, 2024
1 parent f33237b commit ae0f5e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix for domain parsing",
"packageName": "@acedatacloud/nexior",
"email": "office@acedata.cloud",
"dependentChangeType": "patch"
}
9 changes: 6 additions & 3 deletions src/utils/initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ae0f5e9

Please sign in to comment.