diff --git a/src/components/navigation/www/navigation.jsx b/src/components/navigation/www/navigation.jsx index 6950aa2b4..74dce2b80 100644 --- a/src/components/navigation/www/navigation.jsx +++ b/src/components/navigation/www/navigation.jsx @@ -171,7 +171,7 @@ var Navigation = React.createClass({ this.closeRegistration(); }, onSearchSubmit: function (formData) { - window.location.href = '/search/projects?q=' + formData.q; + window.location.href = '/search/projects?q=' + encodeURIComponent(formData.q); }, render: function () { var classes = classNames({ diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx index 334c0c1f0..f3d0e5e1c 100644 --- a/src/views/search/search.jsx +++ b/src/views/search/search.jsx @@ -21,13 +21,25 @@ require('./search.scss'); var Search = injectIntl(React.createClass({ type: 'Search', getDefaultProps: function () { - var query = window.location.search; var pathname = window.location.pathname.toLowerCase(); if (pathname[pathname.length - 1] === '/') { pathname = pathname.substring(0, pathname.length - 1); } var start = pathname.lastIndexOf('/'); var type = pathname.substring(start + 1, pathname.length); + return { + tab: type, + loadNumber: 16 + }; + }, + getInitialState: function () { + return { + loaded: [], + offset: 0 + }; + }, + componentDidMount: function () { + var query = window.location.search; var q = query.lastIndexOf('q='); var term = ''; if (q !== -1) { @@ -40,22 +52,8 @@ var Search = injectIntl(React.createClass({ term = term.substring(0, term.indexOf('&')); } term = term.split('+').join(' '); - - return { - tab: type, - searchTerm: term, - loadNumber: 16 - }; - }, - getInitialState: function () { - return { - loaded: [], - offset: 0 - }; - }, - componentDidMount: function () { this.getSearchMore(); - this.props.dispatch(navigationActions.setSearchTerm(this.props.searchTerm)); + this.props.dispatch(navigationActions.setSearchTerm(decodeURI(term))); }, getSearchMore: function () { var termText = ''; @@ -113,7 +111,7 @@ var Search = injectIntl(React.createClass({ @@ -143,7 +141,7 @@ var Search = injectIntl(React.createClass({ var mapStateToProps = function (state) { return { - navigation: state.searchTerm + searchTerm: state.navigation }; };