support secondary public server URL

This commit is contained in:
jeffvli
2025-12-30 21:05:38 -08:00
parent 7aeadb531f
commit 72d0fca28b
16 changed files with 244 additions and 68 deletions
@@ -1,4 +1,25 @@
import { ServerListItem } from '/@/shared/types/domain-types';
export const normalizeServerUrl = (url: string) => {
// Remove trailing slash
return url.endsWith('/') ? url.slice(0, -1) : url;
};
export const getServerUrl = (
server: null | ServerListItem | undefined,
forceRemoteUrl?: boolean,
): string | undefined => {
if (!server) {
return undefined;
}
if (!forceRemoteUrl && !server.preferRemoteUrl) {
return server.url;
}
if (!server.remoteUrl) {
return server.url;
}
return server.remoteUrl;
};