From ae0f5e90a93899b25f30fa656bb316808ce4a6a3 Mon Sep 17 00:00:00 2001 From: Germey Date: Sun, 7 Jul 2024 23:39:12 +0800 Subject: [PATCH] Fix domain parsing (#75) Co-authored-by: AceDataCloud --- ...loud-nexior-8355f8c9-f9da-4367-9fc6-3a2d03d672ba.json | 7 +++++++ src/utils/initializer.ts | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 change/@acedatacloud-nexior-8355f8c9-f9da-4367-9fc6-3a2d03d672ba.json diff --git a/change/@acedatacloud-nexior-8355f8c9-f9da-4367-9fc6-3a2d03d672ba.json b/change/@acedatacloud-nexior-8355f8c9-f9da-4367-9fc6-3a2d03d672ba.json new file mode 100644 index 00000000..df87d801 --- /dev/null +++ b/change/@acedatacloud-nexior-8355f8c9-f9da-4367-9fc6-3a2d03d672ba.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix for domain parsing", + "packageName": "@acedatacloud/nexior", + "email": "office@acedata.cloud", + "dependentChangeType": "patch" +} diff --git a/src/utils/initializer.ts b/src/utils/initializer.ts index 7069930a..a0ae0dd6 100644 --- a/src/utils/initializer.ts +++ b/src/utils/initializer.ts @@ -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);