Commit a94b9d6c authored by Robert Chen's avatar Robert Chen Committed by Benjamin Wheeler

Fix gh-1934: Search bar special chars (#2075)

* Fixed Issue 1934

The text was encoded once already by the search bar. That means we need to decode it twice in order to decode special characters.

* Rewrote search query parsing
parent 337a9e2f
......@@ -57,12 +57,21 @@ class Search extends React.Component {
}
componentDidMount () {
const query = window.location.search;
const q = query.lastIndexOf('q=');
let term = '';
if (q !== -1) {
term = query.substring(q + 2, query.length).toLowerCase();
}
const query = decodeURIComponent(window.location.search);
let term = query;
const stripQueryValue = function (queryTerm) {
const queryIndex = query.indexOf('q=');
if (queryIndex !== -1) {
queryTerm = query.substring(queryIndex + 2, query.length).toLowerCase();
}
return queryTerm;
};
// Strip off the initial "?q="
term = stripQueryValue(term);
// Strip off user entered "?q="
term = stripQueryValue(term);
while (term.indexOf('/') > -1) {
term = term.substring(0, term.indexOf('/'));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment