bodyparser
bodyparser copied to clipboard
auto charset decoding support
not sure req.charset will be deprecated.
close now ?
I'd like to raise the question about detection of charset encoding while parsing body data. I'm facing with problem when I interact with an external resource and this resource use callback url to return requested data. The resource requests my callback route and provide data in ISO-8895-1 (Latin-1) encoding. But all other routes should work with data in utf-8 encoding. An option to allow bodyparser detect encoding based on request header could be usefull for me.
@RidgeA I had a similar issue, here is what you can do until such option exists.
app.use(async (ctx, next) => {
const encoding = (ctx.path.startsWith('/my/special/route')) ? 'iso-8859-1' : 'utf8';
await bodyParser({
encoding,
})(ctx, next);
});
Closing, feel free to reopen