Authored by 郝肖肖

'url编码try-catch'

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