added search url encoding

This commit is contained in:
Fishandchips321 2026-03-02 18:08:55 +00:00
parent 6a47760cbf
commit cdbfb8c185
3 changed files with 7 additions and 2 deletions

View file

@ -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<IActionResult> 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);
}

View file

@ -9,6 +9,9 @@ const ServerList = () => {
useEffect(() => {
getServerList().then(serverList => {
setServers(serverList);
}).catch(err => {
setServers([]);
alert(err);
})
}, []);

View file

@ -11,7 +11,7 @@ export interface SearchResult {
}
export const search = async (searchTerm: string, serverId: string): Promise<Array<SearchResult>> => {
const response = await axios.get<Array<SearchResult>>(`${apiUrl}/search?searchTerm=${searchTerm}&serverId=${serverId}`);
const response = await axios.get<Array<SearchResult>>(encodeURI(`${apiUrl}/search?searchTerm=${searchTerm}&serverId=${serverId}`));
return response.data;
}