mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 14:08:38 +00:00
feat: upgrade libraries for dependabot alerts (#3300)
* feat: upgrade libraries and code cleanup
This commit is contained in:
30
packages/bruno-tests/src/utils/xmlParser.js
Normal file
30
packages/bruno-tests/src/utils/xmlParser.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const { XMLParser } = require('fast-xml-parser');
|
||||
|
||||
const xmlParser = () => {
|
||||
const parser = new XMLParser({
|
||||
ignoreAttributes: false,
|
||||
allowBooleanAttributes: true,
|
||||
});
|
||||
|
||||
return (req, res, next) => {
|
||||
if (req.is('application/xml') || req.is('text/xml')) {
|
||||
let data = '';
|
||||
req.setEncoding('utf8');
|
||||
req.on('data', (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
req.on('end', () => {
|
||||
try {
|
||||
req.body = parser.parse(data);
|
||||
next();
|
||||
} catch (err) {
|
||||
res.status(400).send('Invalid XML');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = xmlParser;
|
||||
Reference in New Issue
Block a user