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()
}
const mapper = new Morph()
const mapper = new Morph({
types: {
bool: v => {
if (v === 'false') return false
return Boolean(v)
}
}
})
const mappings = [
'bg:backgroundColor',
't:theme',
'l:language',
'ds:dropShadow',
'wc:windowControls',
'wa:widthAdjustment',
'pv:paddingVertical',
'ph:paddingHorizontal',
'ln:lineNumbers',
'code:code'
{ field: 'bg:backgroundColor' },
{ field: 't:theme' },
{ field: 'l:language' },
{ field: 'ds:dropShadow', type: 'bool' },
{ field: 'wc:windowControls', type: 'bool' },
{ field: 'wa:widthAdjustment', type: 'bool' },
{ field: 'pv:paddingVertical' },
{ field: 'ph:paddingHorizontal' },
{ field: 'ln:lineNumbers', type: 'bool' },
{ field: 'code:code' }
]
const reverseMappings = mappings.map(field =>
field
const reverseMappings = mappings.map(mapping =>
Object.assign({}, mapping, {
field: mapping.field
.split(':')
.reverse()
.join(':')
})
)
const keysToQuery = keys =>

Loading…
Cancel
Save