Skip to content

Commit

Permalink
fix(www): avoid querying for no-cache=1 (gatsbyjs#10389)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv authored and gpetrioli committed Jan 22, 2019
1 parent 1f10791 commit bdd70e5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions www/src/components/plugin-searchbar-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ injectGlobal`

// Search shows a list of "hits", and is a child of the PluginSearchBar component
class Search extends Component {
constructor(props, context) {
super(props)
}

render() {
return (
<div
Expand Down Expand Up @@ -253,7 +249,7 @@ class Search extends Component {
<Result
hit={result.hit}
pathname={this.props.pathname}
search={this.props.searchState}
query={this.props.query}
/>
)}
/>
Expand Down Expand Up @@ -415,7 +411,8 @@ class PluginSearchBar extends Component {

urlToSearch = () => {
if (this.props.location.search) {
return this.props.location.search.slice(2)
// ignore this automatically added query parameter
return this.props.location.search.replace(`no-cache=1`, ``).slice(2)
}
return ``
}
Expand All @@ -426,7 +423,7 @@ class PluginSearchBar extends Component {
})
}

onSearchStateChange(searchState) {
onSearchStateChange = searchState => {
this.updateHistory(searchState)
this.setState({ searchState })
}
Expand All @@ -439,11 +436,11 @@ class PluginSearchBar extends Component {
appId="OFCNCOG2CU"
indexName="npm-search"
searchState={this.state.searchState}
onSearchStateChange={this.onSearchStateChange.bind(this)}
onSearchStateChange={this.onSearchStateChange}
>
<Search
pathname={this.props.location.pathname}
searchState={this.state.searchState.query}
query={this.state.searchState.query}
/>
</InstantSearch>
</div>
Expand Down

0 comments on commit bdd70e5

Please sign in to comment.