mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-25 01:28:16 +00:00
* fix issue #2251 by including queryString to get nested action * only use nested query string when original queryString exists, and include test cases
This commit is contained in:
parent
df788fd9ac
commit
27d496c268
@ -357,10 +357,11 @@ export default (
|
|||||||
// get the action for the path AFTER the matched path for this
|
// get the action for the path AFTER the matched path for this
|
||||||
// router
|
// router
|
||||||
let nestedAction;
|
let nestedAction;
|
||||||
|
let nestedQueryString = queryString ? '?' + queryString : '';
|
||||||
if (childRouters[matchedRouteName]) {
|
if (childRouters[matchedRouteName]) {
|
||||||
nestedAction = childRouters[matchedRouteName].getActionForPathAndParams(
|
nestedAction = childRouters[matchedRouteName].getActionForPathAndParams(
|
||||||
/* $FlowFixMe */
|
/* $FlowFixMe */
|
||||||
pathMatch.slice(pathMatchKeys.length).join('/')
|
pathMatch.slice(pathMatchKeys.length).join('/') + nestedQueryString
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,4 +902,66 @@ describe('StackRouter', () => {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Querystring params get passed to nested deep link', () => {
|
||||||
|
// uri with two non-empty query param values
|
||||||
|
const uri = 'main/p/4/list/10259959195?code=test&foo=bar';
|
||||||
|
const action = TestStackRouter.getActionForPathAndParams(uri);
|
||||||
|
expect(action).toEqual({
|
||||||
|
type: NavigationActions.NAVIGATE,
|
||||||
|
routeName: 'main',
|
||||||
|
params: {
|
||||||
|
code: 'test',
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: NavigationActions.NAVIGATE,
|
||||||
|
routeName: 'profile',
|
||||||
|
params: {
|
||||||
|
id: '4',
|
||||||
|
code: 'test',
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: NavigationActions.NAVIGATE,
|
||||||
|
routeName: 'list',
|
||||||
|
params: {
|
||||||
|
id: '10259959195',
|
||||||
|
code: 'test',
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// uri with one empty and one non-empty query param value
|
||||||
|
const uri2 = 'main/p/4/list/10259959195?code=&foo=bar';
|
||||||
|
const action2 = TestStackRouter.getActionForPathAndParams(uri2);
|
||||||
|
expect(action2).toEqual({
|
||||||
|
type: NavigationActions.NAVIGATE,
|
||||||
|
routeName: 'main',
|
||||||
|
params: {
|
||||||
|
code: '',
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: NavigationActions.NAVIGATE,
|
||||||
|
routeName: 'profile',
|
||||||
|
params: {
|
||||||
|
id: '4',
|
||||||
|
code: '',
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: NavigationActions.NAVIGATE,
|
||||||
|
routeName: 'list',
|
||||||
|
params: {
|
||||||
|
id: '10259959195',
|
||||||
|
code: '',
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user