From 082df3a253af974a6caabffe4e90ba0bb6d8038e Mon Sep 17 00:00:00 2001 From: Abhishek Panwar Date: Fri, 20 Dec 2024 02:01:32 +0530 Subject: [PATCH] Fix: Correct URL Encoding in SearchBar Component Changes Made: Used encodeURIComponent in the SearchBar component to ensure special characters and spaces in search queries are correctly encoded. Example: Before: Searching Alexa & Katie could break the query, returning incomplete results. After: The query is now encoded as Alexa%20%26%20Katie, ensuring accurate results. --- src/common/NavBar/HorizontalNavBar/SearchBar/SearchBar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/NavBar/HorizontalNavBar/SearchBar/SearchBar.js b/src/common/NavBar/HorizontalNavBar/SearchBar/SearchBar.js index 40cfbed06..f9e4176bd 100644 --- a/src/common/NavBar/HorizontalNavBar/SearchBar/SearchBar.js +++ b/src/common/NavBar/HorizontalNavBar/SearchBar/SearchBar.js @@ -61,7 +61,7 @@ const SearchBar = React.memo(({ className, query, active }) => { const queryInputOnSubmit = React.useCallback((event) => { event.preventDefault(); - const searchValue = `/search?search=${event.target.value}`; + const searchValue = `/search?search=${encodeURIComponent(event.target.value)}`; setCurrentQuery(searchValue); if (searchInputRef.current && searchValue) { window.location.hash = searchValue;