-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Is your feature request related to a problem? Please describe.
Because of escaping characters on the key, I can't able to add brackets in key without having escaped characters.
Lines 21 to 23 in b1d83a0
key = encodeURIComponent(key) | |
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent) | |
.replace(/[()]/g, escape) |
Describe the solution you'd like
I'm suggesting to have a additional way to override the key replacers same as with the value.
Lines 308 to 312 in b1d83a0
Cookies.withConverter({ | |
write: function (value, name) { | |
return value.toUpperCase() | |
} | |
}) |
to have something like this definition
Cookies.withConverter({
write: function (value, name) {
return String(value).toUpperCase()
}
})
and in additional, this definition to have an overloaded return type to keep both definition exist.
Cookies.withConverter({
write: function(value, key) {
return {
key: String(key),
value: String(value).toUpperCase()
}
}
})
Describe alternatives you've considered
Passing additional optional parameter to disable escapers.
Cookies.set('name', 'value', {
unescapedName: true,
unescapedValue: true,
//...
});
Additional context
I know this solution can expect this this answer #590 (comment) . I'm only suggesting to have an optional way to avoid complying to standards.
Such as this
Lines 5 to 10 in b1d83a0
write: function (value) { | |
return encodeURIComponent(value).replace( | |
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, | |
decodeURIComponent | |
) | |
} |