fix: update currentOrgDomain to derive root domain from window location
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import { browser, dev } from '$app/environment';
|
|
||||||
import { env } from '$env/dynamic/public';
|
|
||||||
import { ROLE } from '$lib/utils/constants/roles';
|
|
||||||
import type { UserLessonDataType } from '$lib/utils/types';
|
|
||||||
import { PLAN } from 'shared/src/plans/constants';
|
|
||||||
import type { Writable } from 'svelte/store';
|
|
||||||
import { derived, writable } from 'svelte/store';
|
|
||||||
import { STEPS } from '../constants/quiz';
|
|
||||||
import type { CurrentOrg, OrgAudience, OrgTeamMember } from '../types/org';
|
import type { CurrentOrg, OrgAudience, OrgTeamMember } from '../types/org';
|
||||||
|
import { browser, dev } from '$app/environment';
|
||||||
|
import { derived, writable } from 'svelte/store';
|
||||||
|
|
||||||
|
import { PLAN } from 'shared/src/plans/constants';
|
||||||
|
import { ROLE } from '$lib/utils/constants/roles';
|
||||||
|
import { STEPS } from '../constants/quiz';
|
||||||
|
import type { UserLessonDataType } from '$lib/utils/types';
|
||||||
|
import type { Writable } from 'svelte/store';
|
||||||
|
import { env } from '$env/dynamic/public';
|
||||||
|
|
||||||
export const defaultCurrentOrgState: CurrentOrg = {
|
export const defaultCurrentOrgState: CurrentOrg = {
|
||||||
id: '',
|
id: '',
|
||||||
@@ -45,12 +46,25 @@ export const currentOrgPath = derived(currentOrg, ($currentOrg) =>
|
|||||||
|
|
||||||
export const currentOrgDomain = derived(currentOrg, ($currentOrg) => {
|
export const currentOrgDomain = derived(currentOrg, ($currentOrg) => {
|
||||||
const browserOrigin = dev && browser && window.location.origin;
|
const browserOrigin = dev && browser && window.location.origin;
|
||||||
|
|
||||||
|
// Get the root domain from window.location
|
||||||
|
let rootDomain = '';
|
||||||
|
if (browser && typeof window !== 'undefined') {
|
||||||
|
const host = window.location.hostname;
|
||||||
|
const parts = host.split('.');
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
rootDomain = parts.slice(-2).join('.');
|
||||||
|
} else {
|
||||||
|
rootDomain = host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return browserOrigin
|
return browserOrigin
|
||||||
? browserOrigin
|
? browserOrigin
|
||||||
: $currentOrg.customDomain && $currentOrg.isCustomDomainVerified
|
: $currentOrg.customDomain && $currentOrg.isCustomDomainVerified
|
||||||
? `https://${$currentOrg.customDomain}`
|
? `https://${$currentOrg.customDomain}`
|
||||||
: $currentOrg.siteName
|
: $currentOrg.siteName
|
||||||
? `https://${$currentOrg.siteName}.classroomio.com`
|
? `https://${$currentOrg.siteName}.${rootDomain}`
|
||||||
: '';
|
: '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user