1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

Merge pull request #130 from oceanprotocol/fix/search-term

url encode & decode search term
This commit is contained in:
Matthias Kretschmann 2019-05-16 15:08:06 +02:00 committed by GitHub
commit c7418a172c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,7 @@ export default class Search extends PureComponent<SearchProps, SearchState> {
const searchPage = queryString.parse(this.props.location.search).page const searchPage = queryString.parse(this.props.location.search).page
await this.setState({ await this.setState({
searchTerm: JSON.stringify(searchTerm) searchTerm: encodeURIComponent(`${searchTerm}`)
}) })
// switch to respective page if query string is present // switch to respective page if query string is present
@ -60,7 +60,7 @@ export default class Search extends PureComponent<SearchProps, SearchState> {
offset: this.state.offset, offset: this.state.offset,
page: this.state.currentPage, page: this.state.currentPage,
query: { query: {
text: [this.state.searchTerm], text: [decodeURIComponent(this.state.searchTerm)],
price: [-1, 1] price: [-1, 1]
}, },
sort: { sort: {
@ -117,9 +117,9 @@ export default class Search extends PureComponent<SearchProps, SearchState> {
<h2 <h2
className={styles.resultsTitle} className={styles.resultsTitle}
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: `${totalResults} results for <span>${ __html: `${totalResults} results for <span>${decodeURIComponent(
this.state.searchTerm this.state.searchTerm
}</span>` )}</span>`
}} }}
/> />
)} )}