diff --git a/src/utils/__test__/parseBalancer.test.ts b/src/utils/__test__/parseBalancer.test.ts index 91cf52846..221a7761d 100644 --- a/src/utils/__test__/parseBalancer.test.ts +++ b/src/utils/__test__/parseBalancer.test.ts @@ -61,12 +61,23 @@ describe('parseBalancer', () => { }); describe('removeViewerPathname', () => { - test('should remove pathname', () => { + test('should remove /viewer/json pathname', () => { const initialValue = 'https://ydb-testing-0000.search.net:8765/viewer/json'; const result = 'https://ydb-testing-0000.search.net:8765'; expect(removeViewerPathname(initialValue)).toBe(result); }); + test('should remove /viewer pathname', () => { + const initialValue = 'https://ydb-testing-0000.search.net:8765/viewer'; + const result = 'https://ydb-testing-0000.search.net:8765'; + + expect(removeViewerPathname(initialValue)).toBe(result); + }); + test('should not change input if there is no /viewer or /viewer/json', () => { + const initialValue = 'https://ydb-testing-0000.search.net:8765'; + + expect(removeViewerPathname(initialValue)).toBe(initialValue); + }); }); describe('removeProtocol', () => { test('should remove protocol from start', () => { diff --git a/src/utils/parseBalancer.ts b/src/utils/parseBalancer.ts index 37d3e6d71..1c64f1e88 100644 --- a/src/utils/parseBalancer.ts +++ b/src/utils/parseBalancer.ts @@ -1,7 +1,7 @@ import {normalizePathSlashes} from '.'; const protocolRegex = /^http[s]?:\/\//; -const viewerPathnameRegex = /\/viewer\/json$/; +const viewerPathnameRegex = /\/viewer(\/json)?$/; export const removeViewerPathname = (value: string) => { return value.replace(viewerPathnameRegex, '');