A javascript library for simplifying encoding and decoding URL query parameters
createEnumParam
to allow only specified string values to be decoded #36equals
method on parameters #24breaking Changes the way empty string/null/undefined values are handled #20. Now null and empty strings are kept. Invalid values will either be null or NaN depending on type (previously became undefined). This allows more direct mapping of query parameter values to what we get in the code and the following cases: ?foo
?foo=
.
Adds a withDefault()
function #21 that wraps parameters to provide a default value with correct types. e.g. if you want the old behavior where null becomes undefined, you can do withDefault(ArrayParam, undefined)
or if you just want to set the default value of a parameter, you set it as the second argument. withDefault(ArrayParam, [])
. If you do not want nulls to be considered as undefined for the purposes of populating a default value, pass false as the third argument.