File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -5,26 +5,36 @@ import { LOCATION_CHANGE } from './actions'
5
5
* Utilises the search prop of location to construct query.
6
6
*/
7
7
const injectQuery = ( location ) => {
8
- if ( ! location ) return location
8
+ if ( ! location ) {
9
+ return location
10
+ }
9
11
const searchQuery = location . search || window . location . search
10
12
11
13
if ( typeof searchQuery !== 'string' || searchQuery . length === 0 ) {
12
- return { ...location , query : { } }
14
+ return {
15
+ ...location ,
16
+ query : { }
17
+ }
13
18
}
14
19
15
20
// Ignore the `?` part of the search string e.g. ?username=codejockie
16
21
const search = searchQuery . substring ( 1 )
17
-
18
22
// Split the query string on `&` e.g. ?username=codejockie&name=Kennedy
19
23
const queries = search . split ( '&' )
20
24
// Contruct query
21
25
const query = queries . reduce ( ( acc , currentQuery ) => {
22
26
// Split on `=`, to get key and value
23
27
const [ queryKey , queryValue ] = currentQuery . split ( '=' )
24
- return { ...acc , [ queryKey ] : queryValue }
28
+ return {
29
+ ...acc ,
30
+ [ queryKey ] : queryValue
31
+ }
25
32
} , { } )
26
33
27
- return { ...location , query }
34
+ return {
35
+ ...location ,
36
+ query
37
+ }
28
38
}
29
39
30
40
const createConnectRouter = ( structure ) => {
You can’t perform that action at this time.
0 commit comments