Authored by 郝肖肖

'url编码try-catch'

... ... @@ -10,7 +10,7 @@ const utils = '../../../utils';
const api = global.yoho.API;
const _ = require('lodash');
const camelCase = global.yoho.camelCase;
const decodeURIComponentExt = require(`${utils}/string-code`).decodeURIComponentExt;
const decodeURIComponentExt = require(`${utils}/string-process`).decodeURIComponent;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
... ...
... ... @@ -5,7 +5,7 @@
const utils = '../../../utils';
const api = global.yoho.API;
const _ = require('lodash');
const decodeURIComponentExt = require(`${utils}/string-code`).decodeURIComponentExt;
const decodeURIComponentExt = require(`${utils}/string-process`).decodeURIComponent;
const exchange = {
// 获取 换货列表
... ...
... ... @@ -3,9 +3,12 @@
*/
const helpers = global.yoho.helpers;
const stringProcess = require('./../../utils/string-process');
module.exports = () => {
return (req, res, next) => {
req.url = stringProcess.decodeURIComponent(req.url) || '/404';// 错误的网址编码重定向404
if (/^\/home\/orders\/paynew/.test(req.url)) {
// 支付中心,由于微信安全配置限制在 home/orders 路径下,需要转发,误删!!!
req.url = `/cart${req.url}`;
... ...
... ... @@ -14,20 +14,7 @@ const hexToUtf8 = (string) => {
return buf.toString('utf8');
};
const decodeURIComponentExt = (string) => {
try {
string = decodeURIComponent(string);
} catch (e) {
string = '';
console.error(`${string}, err: ${e.message}`);
}
return string;
};
module.exports = {
utf8ToHex,
hexToUtf8,
decodeURIComponentExt
hexToUtf8
};
... ...