From 5af953cd2e4faaef071c34341aa0d74a6b53cb99 Mon Sep 17 00:00:00 2001 From: briandennis Date: Tue, 6 Feb 2018 14:04:40 -0600 Subject: [PATCH] remove empty state values so as not to override defaults --- lib/routing.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/routing.js b/lib/routing.js index af879e2..3dc8f9b 100644 --- a/lib/routing.js +++ b/lib/routing.js @@ -44,7 +44,16 @@ const keysToQuery = keys => .map(key => `${key}=${keys[key]}`) .join('&')}` -export const getQueryStringState = query => mapper.map(mappings, query) +export const getQueryStringState = query => { + const state = mapper.map(mappings, query) + + Object.keys(state).forEach(key => { + if (state[key] === '') state[key] = undefined + }) + + return state +} + export const updateQueryString = state => history.replace({ search: encodeURI(keysToQuery(mapper.map(reverseMappings, state)))