Return correct canonical url for share with domain

This commit is contained in:
Tom Moor
2023-11-01 23:45:41 -04:00
parent 1b73339800
commit a48d8fac88

View File

@@ -14,6 +14,7 @@ import {
BeforeUpdate,
} from "sequelize-typescript";
import { SHARE_URL_SLUG_REGEX } from "@shared/utils/urlHelpers";
import env from "@server/env";
import { ValidationError } from "@server/errors";
import Collection from "./Collection";
import Document from "./Document";
@@ -131,6 +132,11 @@ class Share extends IdModel {
}
get canonicalUrl() {
if (this.domain) {
const url = new URL(env.URL);
return `${url.protocol}//${this.domain}${url.port ? `:${url.port}` : ""}`;
}
return this.urlId
? `${this.team.url}/s/${this.urlId}`
: `${this.team.url}/s/${this.id}`;