Skip to content

Commit

Permalink
fix: GEN-1856 encode and escape search value for the tag search (#18285)
Browse files Browse the repository at this point in the history
* fix: GEN-1856 encode and escape search value for the tag

* fix test

* add missing import
  • Loading branch information
chirag-madlani authored and harshach committed Oct 17, 2024
1 parent 29b5c77 commit e5669ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import tagClassBase, { TagClassBase } from './TagClassBase';

jest.mock('../rest/searchAPI');


jest.mock('./StringsUtils', () => ({
getEncodedFqn: jest.fn().mockReturnValue('test'),
escapeESReservedCharacters: jest.fn().mockReturnValue('test'),
}));

describe('TagClassBase', () => {
beforeEach(() => {
(searchQuery as jest.Mock).mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
import { PAGE_SIZE } from '../constants/constants';
import { SearchIndex } from '../enums/search.enum';
import { searchQuery } from '../rest/searchAPI';
import { escapeESReservedCharacters, getEncodedFqn } from './StringsUtils';

class TagClassBase {
public async getTags(searchText: string, page: number) {
// this is to esacpe and encode any chars which is known by ES search internally
const encodedValue = getEncodedFqn(escapeESReservedCharacters(searchText));
const res = await searchQuery({
query: `*${searchText}*`,
query: `*${encodedValue}*`,
filters: 'disabled:false',
pageNumber: page,
pageSize: PAGE_SIZE,
Expand Down

0 comments on commit e5669ae

Please sign in to comment.