Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(nextjs/ssr): parse params.asPath (#189)
Browse files Browse the repository at this point in the history
There is an edge case where `params.asPath === '/'` and
gets converted to `{'/': null}` as search state.
Checking that we have an `?` before fix this issue.
  • Loading branch information
Maxime Janton authored and mthuret committed Jul 25, 2017
1 parent 6fb8077 commit ae17da0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-instantsearch/examples/next-app/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export default class extends React.Component {
to initialize the searchState.
*/
static async getInitialProps(params) {
const searchState = qs.parse(
params.asPath.substring(params.asPath.indexOf('?') + 1)
);
const searchState = params.asPath.includes('?')
? qs.parse(params.asPath.substring(params.asPath.indexOf('?') + 1))
: {}
const resultsState = await findResultsState(App, { searchState });
return { resultsState, searchState };
}
Expand Down

0 comments on commit ae17da0

Please sign in to comment.