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.
This commit is contained in:
Abhishek Panwar 2024-12-20 02:01:32 +05:30 committed by GitHub
parent 659c3c96d2
commit 082df3a253
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;