diff --git a/backend/src/Controllers/SearchController.cs b/backend/src/Controllers/SearchController.cs index 201ded1..3dc3075 100644 --- a/backend/src/Controllers/SearchController.cs +++ b/backend/src/Controllers/SearchController.cs @@ -1,5 +1,6 @@ using JellyGlass.Services; using Microsoft.AspNetCore.Mvc; +using System.Web; namespace JellyGlass.Controllers; @@ -19,7 +20,8 @@ public class SearchController : ControllerBase [HttpGet] public async Task handleSearch([FromQuery] string searchTerm, string serverId) { - var results = await _service.Search(searchTerm, serverId); + var decodedSearchTerm = HttpUtility.UrlDecode(searchTerm); + var results = await _service.Search(decodedSearchTerm, serverId); return Ok(results); } diff --git a/frontend/src/Components/ServerList/ServerList.tsx b/frontend/src/Components/ServerList/ServerList.tsx index 4d46f88..87e82b4 100644 --- a/frontend/src/Components/ServerList/ServerList.tsx +++ b/frontend/src/Components/ServerList/ServerList.tsx @@ -9,6 +9,9 @@ const ServerList = () => { useEffect(() => { getServerList().then(serverList => { setServers(serverList); + }).catch(err => { + setServers([]); + alert(err); }) }, []); diff --git a/frontend/src/Lib/Search.ts b/frontend/src/Lib/Search.ts index c18b01d..a482286 100644 --- a/frontend/src/Lib/Search.ts +++ b/frontend/src/Lib/Search.ts @@ -11,7 +11,7 @@ export interface SearchResult { } export const search = async (searchTerm: string, serverId: string): Promise> => { - const response = await axios.get>(`${apiUrl}/search?searchTerm=${searchTerm}&serverId=${serverId}`); + const response = await axios.get>(encodeURI(`${apiUrl}/search?searchTerm=${searchTerm}&serverId=${serverId}`)); return response.data; }