Skip to content

Commit

Permalink
fix: Prevent filtering highlighting from crashing when match is >1000…
Browse files Browse the repository at this point in the history
…0 chars (#3290)
  • Loading branch information
avinashbot authored Feb 12, 2025
1 parent 9976a86 commit 2966baa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/internal/components/option/__tests__/option.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ describe('Option component', () => {
test('skips highlighting if the label text is too long', () => {
const optionWrapper = renderOption({
option: {
label: 'a'.repeat(1000000),
label: 'a'.repeat(100000),
value: '1',
},
highlightText: 'a'.repeat(500000),
highlightText: 'a'.repeat(50000),
});
checkMatches(optionWrapper, 0, '');
});
Expand Down
2 changes: 1 addition & 1 deletion src/internal/components/option/highlight-match.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styles from './styles.css.js';
const splitOnFiltering = (str: string, highlightText: string) => {
// We match by creating a regex using user-provided strings, so we skip
// highlighting if the generated regex would be too memory intensive.
if (highlightText.length > 100000) {
if (highlightText.length > 10_000) {
return { noMatches: [str], matches: null };
}

Expand Down

0 comments on commit 2966baa

Please sign in to comment.