Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/utils/__test__/parseBalancer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/parseBalancer.ts
Original file line number Diff line number Diff line change
@@ -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, '');
Expand Down
Loading