mirror of
https://github.com/docmost/docmost.git
synced 2026-06-10 18:16:57 +08:00
25 lines
719 B
TypeScript
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}`;
|
|
}
|
|
}
|