diff --git a/src/__tests__/actionToPath.test.js b/src/__tests__/actionToPath.test.js index 0799d77..f0fbadf 100644 --- a/src/__tests__/actionToPath.test.js +++ b/src/__tests__/actionToPath.test.js @@ -36,7 +36,8 @@ describe('actionToPath', () => { expect( actionToPath( routesMap, - navigate('PROJECT', { projectName: 'Project 123' }, { query: { returnTo: 'home' } }) + navigate('PROJECT', { projectName: 'Project 123' }, + { query: { returnTo: 'home', missing: undefined, unspecified: null } }) ) ).toEqual({ pathname: '/portal/projects/Project%20123', diff --git a/src/core.js b/src/core.js index 52a524e..e2084ae 100644 --- a/src/core.js +++ b/src/core.js @@ -31,6 +31,9 @@ function stringifyQuery(query) { const params = new URLSearchParams(); for (const key in query) { const val = query[key]; + if (val === undefined || val === null) { + continue; + } if (Array.isArray(val)) { for (const _val of val) { params.append(key, _val);