URI component encode carbon text

main
briandennis 7 years ago committed by Brian Dennis
parent 54261b37e8
commit 46091f6dc5

@ -46,6 +46,7 @@ const keysToQuery = keys =>
export const getQueryStringState = query => {
const state = mapper.map(mappings, query)
deserializeCode(state)
Object.keys(state).forEach(key => {
if (state[key] === '') state[key] = undefined
@ -54,7 +55,20 @@ export const getQueryStringState = query => {
return state
}
export const updateQueryString = state =>
export const updateQueryString = state => {
let mappedState = mapper.map(reverseMappings, state)
serializeCode(mappedState)
history.replace({
search: encodeURI(keysToQuery(mapper.map(reverseMappings, state)))
search: encodeURI(keysToQuery(mappedState))
})
}
// private
function serializeCode(state) {
if (state.code) state.code = encodeURIComponent(state.code)
}
function deserializeCode(state) {
if (state.code) state.code = decodeURIComponent(state.code)
}

Loading…
Cancel
Save