Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash outside browser environment #377

Merged
merged 6 commits into from
Nov 25, 2019
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/reducer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { LOCATION_CHANGE } from './actions'

const getSearchQuery = (location) => {
if (location && location.search) {
return location.search
}

if (window && window.location && window.location.search) {
VadimKorobka marked this conversation as resolved.
Show resolved Hide resolved
return window.location.search
}

return ''
}
/**
* Adds query to location.
* Utilises the search prop of location to construct query.
*/
const injectQuery = (location) => {
if (!location) {
return location
}

const searchQuery = location.search || window.location.search
const searchQuery = getSearchQuery(location)

if (typeof searchQuery !== 'string' || searchQuery.length === 0) {
return {
Expand Down