This PR refactors and abstracts jellyfin hostname into, jellyfin ip, jellyfin port, jellyfin useSsl, and jellyfin urlBase. This makes it more consistent with how plex settings are stored as well. In addition, this improves validation as validation can be applied seperately to them instead of as one whole regex doing the work to validate the url. UI was updated to reflect this. BREAKING CHANGE: Jellyfin settings now does not include a hostname. Instead it abstracted it to ip, port, useSsl, and urlBase. However, migration of old settings to new settings should work automatically.
19 lines
434 B
TypeScript
19 lines
434 B
TypeScript
import { getSettings } from '@server/lib/settings';
|
|
|
|
interface HostnameParams {
|
|
useSsl?: boolean;
|
|
ip?: string;
|
|
port?: number;
|
|
urlBase?: string;
|
|
}
|
|
|
|
export const getHostname = (params?: HostnameParams): string => {
|
|
const settings = params ? params : getSettings().jellyfin;
|
|
|
|
const { useSsl, ip, port, urlBase } = settings;
|
|
|
|
const hostname = `${useSsl ? 'https' : 'http'}://${ip}:${port}${urlBase}`;
|
|
|
|
return hostname;
|
|
};
|