Skip to content

Commit b0031e8

Browse files
authored
[CI-3614] Don't send autocomplete requests with queries longer than 200 characters long (#154)
* Do not send a request if the terms is longer than 199 characters * Optimize code
1 parent 45d24e6 commit b0031e8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/hooks/useDebouncedFetchSections.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ const useDebouncedFetchSection = (
9393

9494
useEffect(() => {
9595
(async () => {
96-
if (debouncedSearchTerm.trim()) {
96+
const trimmedTerm = debouncedSearchTerm.trim();
97+
98+
// Do not send a request if the encoded term is longer than 199 characters
99+
if (trimmedTerm && encodeURIComponent(trimmedTerm).length < 200) {
97100
try {
98101
const response = await cioClient?.autocomplete.getAutocompleteResults(
99102
debouncedSearchTerm,

0 commit comments

Comments
 (0)