Skip to content

Commit 4eaf9a2

Browse files
committed
fix code style
1 parent 16bc166 commit 4eaf9a2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/reducer.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,36 @@ import { LOCATION_CHANGE } from './actions'
55
* Utilises the search prop of location to construct query.
66
*/
77
const injectQuery = (location) => {
8-
if (!location) return location
8+
if (!location) {
9+
return location
10+
}
911
const searchQuery = location.search || window.location.search
1012

1113
if (typeof searchQuery !== 'string' || searchQuery.length === 0) {
12-
return { ...location, query: {} }
14+
return {
15+
...location,
16+
query: {}
17+
}
1318
}
1419

1520
// Ignore the `?` part of the search string e.g. ?username=codejockie
1621
const search = searchQuery.substring(1)
17-
1822
// Split the query string on `&` e.g. ?username=codejockie&name=Kennedy
1923
const queries = search.split('&')
2024
// Contruct query
2125
const query = queries.reduce((acc, currentQuery) => {
2226
// Split on `=`, to get key and value
2327
const [queryKey, queryValue] = currentQuery.split('=')
24-
return { ...acc, [queryKey]: queryValue }
28+
return {
29+
...acc,
30+
[queryKey]: queryValue
31+
}
2532
}, {})
2633

27-
return { ...location, query }
34+
return {
35+
...location,
36+
query
37+
}
2838
}
2939

3040
const createConnectRouter = (structure) => {

0 commit comments

Comments
 (0)