Files
docmost/apps/server/src/integrations/environment/domain.service.ts
T
2025-06-28 19:05:03 -07:00

25 lines
719 B
TypeScript

import { Injectable } from '@nestjs/common';
import { EnvironmentService } from './environment.service';
@Injectable()
export class DomainService {
constructor(private environmentService: EnvironmentService) {}
getUrl(hostname?: string, customDomain?: string): string {
if (!this.environmentService.isCloud()) {
return this.environmentService.getAppUrl();
}
if (customDomain) {
return customDomain;
}
const domain = this.environmentService.getSubdomainHost();
if (!hostname || !domain) {
return this.environmentService.getAppUrl();
}
const protocol = this.environmentService.isHttps() ? 'https' : 'http';
return `${protocol}://${hostname}.${domain}`;
}
}