fix: 添加以{}包含变量支持与字符串或其他变量拼接

This commit is contained in:
wnstar 2017-11-12 12:31:24 +08:00
parent 9dbeacc799
commit 880fcd67ed
18 changed files with 19 additions and 9 deletions

View File

@ -226,4 +226,4 @@ exports.safeAssign = (Obj, nextObj) => {
};
exports.simpleJsonPathParse = simpleJsonPathParse;
exports.handleMockWord = handleMockWord;
exports.handleMockWord = handleMockWord;

View File

@ -216,8 +216,8 @@ class InterfaceColContent extends Component {
}
const urlObj = URL.parse(URL.resolve(currDomain.domain, '.' + path));
urlObj.query && urlObj.query.split('&').forEach(item=>{
if(item){
urlObj.query && urlObj.query.split('&').forEach(item => {
if (item) {
item = item.split('=');
pathQuery[item[0]] = item[1];
}
@ -227,7 +227,7 @@ class InterfaceColContent extends Component {
protocol: urlObj.protocol || 'http',
host: urlObj.host,
pathname: urlObj.pathname,
query: Object.assign(pathQuery, this.getQueryObj(interfaceData.req_query, requestParams))
query: Object.assign(pathQuery, this.getQueryObj(interfaceData.req_query, requestParams))
});
let result = { code: 400, msg: '数据异常', validRes: [] };
@ -363,12 +363,22 @@ class InterfaceColContent extends Component {
}
handleValue = (val) => {
const regex = /(\{\$\.\d+\..*?\})|(\{\@\w+\})/g;
if (!val || typeof val !== 'string') {
return val;
} else if (val[0] === '@') {
return handleMockWord(val);
} else if (val.indexOf('$.') === 0) {
return simpleJsonPathParse(val, this.records);
} else if (val.match(regex) !== null) {
val.match(regex).forEach((match) => {
if (match.indexOf("{@") === 0) {
val = val.replace(match, handleMockWord(match.substr(1, match.length - 2)))
} else {
val = val.replace(match, simpleJsonPathParse(match.substr(1, match.length - 2), this.records));
}
});
return val;
}
return val;
}

View File

@ -1 +1 @@
window.WEBPACK_ASSETS = {"index.js":{"js":"index@3ea8285572a5ca4441ca.js","css":"index@3ea8285572a5ca4441ca.css"},"lib":{"js":"lib@9521c6250635e5a8893a.js"},"lib2":{"js":"lib2@dbcc326d4fe3e4473316.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}
window.WEBPACK_ASSETS = {"index.js":{"js":"index@a415de52976a4723e9c3.js","css":"index@a415de52976a4723e9c3.css"},"lib":{"js":"lib@141ad8d5cb20302cc671.js"},"lib2":{"js":"lib2@f9e5f06eb6179b4b5943.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long