From 2f1b8873cf3c9f04cad80141aba9e326ace69e44 Mon Sep 17 00:00:00 2001 From: Alankarsharma Date: Fri, 8 Dec 2023 09:47:38 +0530 Subject: [PATCH] Last check-in was wrong, Fixed it, added test case for this as well. Signed-off-by: Alankarsharma --- src/core/server/rendering/rendering_service.test.ts | 5 +++++ src/core/server/rendering/rendering_service.tsx | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/server/rendering/rendering_service.test.ts b/src/core/server/rendering/rendering_service.test.ts index 56a39915e73c..5fa7d010989e 100644 --- a/src/core/server/rendering/rendering_service.test.ts +++ b/src/core/server/rendering/rendering_service.test.ts @@ -195,6 +195,11 @@ describe('RenderingService', () => { const result = await service.isUrlValid('/', 'config'); expect(result).toEqual(false); }); + + it('checks relative URL returns true', async () => { + const result = await service.isUrlValid('/demo/opensearch_mark_default.png', 'config'); + expect(result).toEqual(true); + }); }); describe('isTitleValid()', () => { diff --git a/src/core/server/rendering/rendering_service.tsx b/src/core/server/rendering/rendering_service.tsx index f78ab722a8c5..dfd1cb5789ef 100644 --- a/src/core/server/rendering/rendering_service.tsx +++ b/src/core/server/rendering/rendering_service.tsx @@ -171,7 +171,7 @@ export class RenderingService { }; } - public async stop() {} + public async stop() { } /** * Setups HTTP Agent if SSL is enabled to pass SSL config @@ -366,12 +366,15 @@ export class RenderingService { */ public isUrlValid = async (url: string, configName?: string): Promise => { if (url === '/') { - return true; + return false; } if (url.match(/\.(png|svg|gif|PNG|SVG|GIF)$/) === null) { this.logger.get('branding').error(`${configName} config is invalid. Using default branding.`); return false; } + if (url.startsWith('/')) { + return true; + } return await Axios.get(url, { httpsAgent: this.httpsAgent, adapter: AxiosHttpAdapter,