Fix boolean params (#195)

* Parse boolean query params properly

* Update routing.js
main
Brad Dougherty 7 years ago committed by Michael Fix
parent d5f786bad9
commit 71e535e9e2

@ -7,26 +7,35 @@ if (typeof window !== 'undefined') {
history = createHistory() history = createHistory()
} }
const mapper = new Morph() const mapper = new Morph({
types: {
bool: v => {
if (v === 'false') return false
return Boolean(v)
}
}
})
const mappings = [ const mappings = [
'bg:backgroundColor', { field: 'bg:backgroundColor' },
't:theme', { field: 't:theme' },
'l:language', { field: 'l:language' },
'ds:dropShadow', { field: 'ds:dropShadow', type: 'bool' },
'wc:windowControls', { field: 'wc:windowControls', type: 'bool' },
'wa:widthAdjustment', { field: 'wa:widthAdjustment', type: 'bool' },
'pv:paddingVertical', { field: 'pv:paddingVertical' },
'ph:paddingHorizontal', { field: 'ph:paddingHorizontal' },
'ln:lineNumbers', { field: 'ln:lineNumbers', type: 'bool' },
'code:code' { field: 'code:code' }
] ]
const reverseMappings = mappings.map(field => const reverseMappings = mappings.map(mapping =>
field Object.assign({}, mapping, {
field: mapping.field
.split(':') .split(':')
.reverse() .reverse()
.join(':') .join(':')
})
) )
const keysToQuery = keys => const keysToQuery = keys =>

Loading…
Cancel
Save