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.
|
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.
|
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
|
write: function (value) { |
|
return encodeURIComponent(value).replace( |
|
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, |
|
decodeURIComponent |
|
) |
|
} |
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.
js-cookie/src/api.mjs
Lines 21 to 23 in b1d83a0
Describe the solution you'd like
I'm suggesting to have a additional way to override the key replacers same as with the value.
js-cookie/README.md
Lines 308 to 312 in b1d83a0
to have something like this definition
and in additional, this definition to have an overloaded return type to keep both definition exist.
Describe alternatives you've considered
Passing additional optional parameter to disable escapers.
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
js-cookie/src/rfc6265.mjs
Lines 5 to 10 in b1d83a0