chore: refactor domain parsing to be more general (#3448)
* change the api of domain parsing to just parseDomain and getCookieDomain * adds getBaseDomain as the method to get the domain after any official subdomains
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
DataType,
|
||||
} from "sequelize-typescript";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { stripSubdomain, RESERVED_SUBDOMAINS } from "@shared/utils/domains";
|
||||
import { getBaseDomain, RESERVED_SUBDOMAINS } from "@shared/utils/domains";
|
||||
import env from "@server/env";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import { generateAvatarUrl } from "@server/utils/avatars";
|
||||
@@ -122,6 +122,7 @@ class Team extends ParanoidModel {
|
||||
}
|
||||
|
||||
get url() {
|
||||
// custom domain
|
||||
if (this.domain) {
|
||||
return `https://${this.domain}`;
|
||||
}
|
||||
@@ -131,7 +132,7 @@ class Team extends ParanoidModel {
|
||||
}
|
||||
|
||||
const url = new URL(env.URL);
|
||||
url.host = `${this.subdomain}.${stripSubdomain(url.host)}`;
|
||||
url.host = `${this.subdomain}.${getBaseDomain()}`;
|
||||
return url.href.replace(/\/$/, "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user