I'm currently working on some project in react and search query is represented as /search/:query.
It works fine when query is "something", but I search for "something/../../else" it change url to "/else".
Route doesn't change but url does.
I use react-router-dom and pathname is updated on search input submit.
this.props.history.push('/search/' + searchValue);
How can I escape searchValue so it doesn't mess up url after submit
Try to escape the search value like this : encodeURIComponent() doc : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent