Skip to content

Commit c37f2e3

Browse files
fix: remove viewer from balancer (#2523)
1 parent 453ff4d commit c37f2e3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/utils/__test__/parseBalancer.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,23 @@ describe('parseBalancer', () => {
6161
});
6262

6363
describe('removeViewerPathname', () => {
64-
test('should remove pathname', () => {
64+
test('should remove /viewer/json pathname', () => {
6565
const initialValue = 'https://ydb-testing-0000.search.net:8765/viewer/json';
6666
const result = 'https://ydb-testing-0000.search.net:8765';
6767

6868
expect(removeViewerPathname(initialValue)).toBe(result);
6969
});
70+
test('should remove /viewer pathname', () => {
71+
const initialValue = 'https://ydb-testing-0000.search.net:8765/viewer';
72+
const result = 'https://ydb-testing-0000.search.net:8765';
73+
74+
expect(removeViewerPathname(initialValue)).toBe(result);
75+
});
76+
test('should not change input if there is no /viewer or /viewer/json', () => {
77+
const initialValue = 'https://ydb-testing-0000.search.net:8765';
78+
79+
expect(removeViewerPathname(initialValue)).toBe(initialValue);
80+
});
7081
});
7182
describe('removeProtocol', () => {
7283
test('should remove protocol from start', () => {

src/utils/parseBalancer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {normalizePathSlashes} from '.';
22

33
const protocolRegex = /^http[s]?:\/\//;
4-
const viewerPathnameRegex = /\/viewer\/json$/;
4+
const viewerPathnameRegex = /\/viewer(\/json)?$/;
55

66
export const removeViewerPathname = (value: string) => {
77
return value.replace(viewerPathnameRegex, '');

0 commit comments

Comments
 (0)