Skip to content

Commit

Permalink
upgrade fuse to latest version (#1559)
Browse files Browse the repository at this point in the history
* upgrade fuse to allow search with longer 32 characters
  • Loading branch information
thanh-nguyen-dang authored Jul 12, 2024
1 parent 2524420 commit 797630f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"enzyme-adapter-react-16": "^1.15.7",
"file-saver": "^1.3.3",
"focus-trap": "^6.5.0",
"fuse.js": "^3.3.0",
"fuse.js": "^7.0.0",
"graphiql": "1.11.5",
"graphql": "^15.0.0",
"graphql-language-service-interface": "^2.8.2",
Expand Down
7 changes: 0 additions & 7 deletions src/DataDictionary/search/DictionarySearcher/searchHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ export const searchKeyword = (searchData, keyword) => {
errorMsg: ERR_KEYWORD_TOO_SHORT,
};
}
// 32 is length limitation of Fuse search library
if (keyword.length > 32) {
return {
result: [],
errorMsg: ERR_KEYWORD_TOO_LONG,
};
}
const halfLength = Math.round(keyword.length / 2);
const minMatchCharLength = Math.min(Math.max(halfLength, 10), keyword.length);
const options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
searchKeyword,
getSearchSummary,
ERR_KEYWORD_TOO_SHORT,
ERR_KEYWORD_TOO_LONG,
ERR_KEYWORD_TOO_LONG, ZERO_RESULT_FOUND_MSG,
} from './searchHelper';

describe('dictionary search helper', () => {
Expand Down Expand Up @@ -78,6 +78,6 @@ describe('dictionary search helper', () => {
it('can output error if keyword too long', () => {
const { result, errorMsg } = searchKeyword(searchData, '1234567890123456789012345678901234567890');
expect(result).toEqual([]);
expect(errorMsg).toEqual(ERR_KEYWORD_TOO_LONG);
expect(errorMsg).toEqual(ZERO_RESULT_FOUND_MSG);
});
});

0 comments on commit 797630f

Please sign in to comment.