mirror of
https://github.com/immich-app/immich.git
synced 2025-01-28 00:59:18 -05:00
fix: normalize external domain (#12831)
chore: normalize external domain
This commit is contained in:
parent
9a4a320cfb
commit
a7719a94fc
3 changed files with 22 additions and 5 deletions
|
@ -120,6 +120,10 @@ export class SystemConfigCore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.server.externalDomain.length > 0) {
|
||||||
|
config.server.externalDomain = new URL(config.server.externalDomain).origin;
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.ffmpeg.acceptedVideoCodecs.includes(config.ffmpeg.targetVideoCodec)) {
|
if (!config.ffmpeg.acceptedVideoCodecs.includes(config.ffmpeg.targetVideoCodec)) {
|
||||||
config.ffmpeg.acceptedVideoCodecs.push(config.ffmpeg.targetVideoCodec);
|
config.ffmpeg.acceptedVideoCodecs.push(config.ffmpeg.targetVideoCodec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,6 +289,23 @@ describe(SystemConfigService.name, () => {
|
||||||
expect(config.machineLearning.url).toEqual('immich_machine_learning');
|
expect(config.machineLearning.url).toEqual('immich_machine_learning');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const externalDomainTests = [
|
||||||
|
{ should: 'with a trailing slash', externalDomain: 'https://demo.immich.app/' },
|
||||||
|
{ should: 'without a trailing slash', externalDomain: 'https://demo.immich.app' },
|
||||||
|
{ should: 'with a port', externalDomain: 'https://demo.immich.app:42', result: 'https://demo.immich.app:42' },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const { should, externalDomain, result } of externalDomainTests) {
|
||||||
|
it(`should normalize an external domain ${should}`, async () => {
|
||||||
|
process.env.IMMICH_CONFIG_FILE = 'immich-config.json';
|
||||||
|
const partialConfig = { server: { externalDomain } };
|
||||||
|
systemMock.readFile.mockResolvedValue(JSON.stringify(partialConfig));
|
||||||
|
|
||||||
|
const config = await sut.getConfig();
|
||||||
|
expect(config.server.externalDomain).toEqual(result ?? 'https://demo.immich.app');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
it('should warn for unknown options in yaml', async () => {
|
it('should warn for unknown options in yaml', async () => {
|
||||||
process.env.IMMICH_CONFIG_FILE = 'immich-config.yaml';
|
process.env.IMMICH_CONFIG_FILE = 'immich-config.yaml';
|
||||||
const partialConfig = `
|
const partialConfig = `
|
||||||
|
|
|
@ -257,11 +257,7 @@ export const copyToClipboard = async (secret: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const makeSharedLinkUrl = (externalDomain: string, key: string) => {
|
export const makeSharedLinkUrl = (externalDomain: string, key: string) => {
|
||||||
let url = externalDomain || window.location.origin;
|
return new URL(`share/${key}`, externalDomain || window.location.origin).href;
|
||||||
if (!url.endsWith('/')) {
|
|
||||||
url += '/';
|
|
||||||
}
|
|
||||||
return `${url}share/${key}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const oauth = {
|
export const oauth = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue