From c5a4a15a3affc150f37bcc46a3286a97419c6ae0 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 16 May 2019 13:27:41 +0200 Subject: [PATCH] url encode & decode search term --- client/src/routes/Search.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/routes/Search.tsx b/client/src/routes/Search.tsx index 4036b4b..f8832c5 100644 --- a/client/src/routes/Search.tsx +++ b/client/src/routes/Search.tsx @@ -41,7 +41,7 @@ export default class Search extends PureComponent { const searchPage = queryString.parse(this.props.location.search).page await this.setState({ - searchTerm: JSON.stringify(searchTerm) + searchTerm: encodeURIComponent(`${searchTerm}`) }) // switch to respective page if query string is present @@ -60,7 +60,7 @@ export default class Search extends PureComponent { offset: this.state.offset, page: this.state.currentPage, query: { - text: [this.state.searchTerm], + text: [decodeURIComponent(this.state.searchTerm)], price: [-1, 1] }, sort: { @@ -117,9 +117,9 @@ export default class Search extends PureComponent {

${ + __html: `${totalResults} results for ${decodeURIComponent( this.state.searchTerm - }` + )}` }} /> )}