Authored by 张丽霞

Url拼接type保护,review by 盖见秋

... ... @@ -21,12 +21,20 @@ export function urlAddParamOfType(url, type='0') {
dataString = strs[1];
}
}
var obj = JSON.parse(dataString); //由JSON字符串转换为JSON对象
obj.params.type = type + ''; // params增加type参数
let totalUrlWithType = "yohobuy=" + JSON.stringify(obj);
if (strs.length > 1) {
totalUrlWithType = strs[0] + totalUrlWithType;
try {
var obj = {};
if (dataString.length > 1) {
obj = JSON.parse(dataString); //由JSON字符串转换为JSON对象
}
obj.params.type = type + ''; // params增加type参数
let totalUrlWithType = "yohobuy=" + JSON.stringify(obj);
if (strs.length > 1) {
totalUrlWithType = strs[0] + totalUrlWithType;
}
return totalUrlWithType;
} catch (e) {
}
return totalUrlWithType;
}
\ No newline at end of file
}
... ...
... ... @@ -13,6 +13,7 @@ const {
SWITCH_GENDER,
JUMP_WITH_URL,
} = require('../../constants/actionTypes').default;
import {urlAddParamOfType} from '../../../common/utils/urlHandler';
export function setSegment(segment) {
return {
... ... @@ -157,37 +158,11 @@ export function jumpWithUrl(url) {
return;
}
//拼接type
url = urlAddParamOfType(url);
url = urlAddParamOfType(url, '7')
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
return {
type: JUMP_WITH_URL,
payload: url
};
}
function urlAddParamOfType(url) {
let strs= new Array();
let dataString = '';
if (url.indexOf('yohobuy=') !== -1) {
strs = url.split("yohobuy=");
if (strs.length == 1) {
dataString = strs[0];
} else {
dataString = strs[1];
}
} else {
strs = url.split("yohobuy=");
if (strs.length == 1) {
dataString = strs[0];
} else {
dataString = strs[1];
}
}
var obj = JSON.parse(dataString); //由JSON字符串转换为JSON对象
obj.params.type = '7';
let totalUrlWithType = "yohobuy=" + JSON.stringify(obj);
if (strs.length > 1) {
totalUrlWithType = strs[0] + totalUrlWithType;
}
return totalUrlWithType;
}
... ...