added search url encoding
This commit is contained in:
parent
6a47760cbf
commit
cdbfb8c185
3 changed files with 7 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using JellyGlass.Services;
|
using JellyGlass.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
namespace JellyGlass.Controllers;
|
namespace JellyGlass.Controllers;
|
||||||
|
|
||||||
|
|
@ -19,7 +20,8 @@ public class SearchController : ControllerBase
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> handleSearch([FromQuery] string searchTerm, string serverId)
|
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);
|
return Ok(results);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ const ServerList = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getServerList().then(serverList => {
|
getServerList().then(serverList => {
|
||||||
setServers(serverList);
|
setServers(serverList);
|
||||||
|
}).catch(err => {
|
||||||
|
setServers([]);
|
||||||
|
alert(err);
|
||||||
})
|
})
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export interface SearchResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const search = async (searchTerm: string, serverId: string): Promise<Array<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;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue