From 4a7c8b1cdd5334e75a95da5e329fb2f91d6a24e4 Mon Sep 17 00:00:00 2001 From: mufazalov Date: Tue, 1 Jul 2025 22:18:06 +0300 Subject: [PATCH] fix: remove viewer from balancer --- src/utils/__test__/parseBalancer.test.ts | 13 ++++++++++++- src/utils/parseBalancer.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) 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, '');