Skip to content

Commit

Permalink
Last check-in was wrong,
Browse files Browse the repository at this point in the history
Fixed it, added test case for this as well.

Signed-off-by: Alankarsharma <[email protected]>
  • Loading branch information
Alankarsharma committed Dec 8, 2023
1 parent 4e66b1b commit 856e434
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/core/server/rendering/rendering_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down
7 changes: 5 additions & 2 deletions src/core/server/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class RenderingService {
};
}

public async stop() {}
public async stop() { }

/**
* Setups HTTP Agent if SSL is enabled to pass SSL config
Expand Down Expand Up @@ -366,12 +366,15 @@ export class RenderingService {
*/
public isUrlValid = async (url: string, configName?: string): Promise<boolean> => {
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,
Expand Down

0 comments on commit 856e434

Please sign in to comment.