|
|
@ -80,6 +80,7 @@ export const getQueryStringState = query => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const state = mapper.map(mappings, query)
|
|
|
|
const state = mapper.map(mappings, query)
|
|
|
|
|
|
|
|
deserializeCode(state)
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(state).forEach(key => {
|
|
|
|
Object.keys(state).forEach(key => {
|
|
|
|
if (state[key] === '') state[key] = undefined
|
|
|
|
if (state[key] === '') state[key] = undefined
|
|
|
@ -91,10 +92,27 @@ export const getQueryStringState = query => {
|
|
|
|
export const updateQueryString = state => {
|
|
|
|
export const updateQueryString = state => {
|
|
|
|
if (history.location.search.indexOf('react_perf') < 0) {
|
|
|
|
if (history.location.search.indexOf('react_perf') < 0) {
|
|
|
|
const mappedState = mapper.map(reverseMappings, state)
|
|
|
|
const mappedState = mapper.map(reverseMappings, state)
|
|
|
|
|
|
|
|
serializeCode(mappedState)
|
|
|
|
|
|
|
|
|
|
|
|
history.replace({
|
|
|
|
history.replace({
|
|
|
|
// Do NOT change this to encodeURIComponent
|
|
|
|
|
|
|
|
search: encodeURI(keysToQuery(mappedState))
|
|
|
|
search: encodeURI(keysToQuery(mappedState))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private
|
|
|
|
|
|
|
|
function serializeCode(state) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (state.code) state.code = encodeURIComponent(state.code)
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
// encoding errors should not crash the app
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function deserializeCode(state) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (state.code) state.code = decodeURIComponent(state.code)
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
// decoding errors should not crash the app
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|