diff --git a/src/core/server/rendering/rendering_service.test.ts b/src/core/server/rendering/rendering_service.test.ts index 61a7f0ce3dea..e4d52dc13648 100644 --- a/src/core/server/rendering/rendering_service.test.ts +++ b/src/core/server/rendering/rendering_service.test.ts @@ -163,6 +163,11 @@ describe('RenderingService', () => { const result = await service.isUrlValid('http://notfound.svg', 'config'); expect(result).toEqual(false); }); + + it('checks default URL returns false', async () => { + const result = await service.isUrlValid('/', 'config'); + expect(result).toEqual(false); + }); }); describe('isTitleValid()', () => { diff --git a/src/core/server/rendering/rendering_service.tsx b/src/core/server/rendering/rendering_service.tsx index efaab2b94947..5185ef6a6154 100644 --- a/src/core/server/rendering/rendering_service.tsx +++ b/src/core/server/rendering/rendering_service.tsx @@ -315,8 +315,11 @@ export class RenderingService { * @returns {boolean} indicate if the URL is valid/invalid */ public isUrlValid = async (url: string, configName?: string): Promise => { + if (url === '/') { + return false; + } if (url.match(/\.(png|svg|gif|PNG|SVG|GIF)$/) === null) { - this.logger.get('branding').info(configName + ' config is not found or invalid.'); + this.logger.get('branding').error(`${configName} config is invalid. Using default branding.`); return false; } return await Axios.get(url, { adapter: AxiosHttpAdapter, maxRedirects: 0 }) @@ -324,7 +327,9 @@ export class RenderingService { return true; }) .catch(() => { - this.logger.get('branding').info(configName + ' config is not found or invalid'); + this.logger + .get('branding') + .error(`${configName} URL was not found or invalid. Using default branding.`); return false; }); }; @@ -338,12 +343,14 @@ export class RenderingService { * @returns {boolean} indicate if user input title is valid/invalid */ public isTitleValid = (title: string, configName?: string): boolean => { - if (!title || title.length > 36) { + if (!title) { + return false; + } + if (title.length > 36) { this.logger .get('branding') - .info( - configName + - ' config is not found or invalid. Title length should be between 1 to 36 characters.' + .error( + `${configName} config is not found or invalid. Title length should be between 1 to 36 characters. Using default title.` ); return false; }