gbk2utf.js
469 Bytes
'use strict';
const urlEncode = require('urlencode');
const _ = require('lodash');
module.exports = (req, res, next) => {
let query = _.trim(req.query.query);
if (query) {
try {
query = urlEncode.decode(query);
} catch (e) {
try {
query = urlEncode.decode(query, 'gbk');
req.query.query = query;
} catch (e1) {} // eslint-disable-line
}
}
return next();
};