Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn committed Jun 10, 2014
1 parent dfe7b18 commit 864de58
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions UPDATELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### RAP v0.9.1 ###
* [功能] 支持MockJS自定义函数,在有@mock=标签时忽略;分割表达式。修复控制台不显示MockJS自定义函数的问题。
* [功能] 参数化MockJS模板生成现在支持Key了(以前只支持value)。2014-05-29
* [BUG] 修复RESTful正则语法的BUG。2014-05-29

Expand Down
4 changes: 2 additions & 2 deletions WebContent/stat/js/util/mock-min.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions WebContent/tester/pageTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,28 @@ YUI().use('handlebars', 'node', 'event', 'jsonp', 'jsonp-url', 'json-stringify',
return obj;
}
}

function convertFuncValsToString(obj) {
if (typeof obj !== 'object' || obj === null) {
return;
}
var key, val;
for (key in obj) {
val = obj[key];
if (obj.hasOwnProperty(key)) {
if (typeof val === 'function') {
obj[key] = val.toString();
} else {
convertFuncValsToString(obj[key]);
}
}
}
}



function testResHandler(response, form, btn) {
convertFuncValsToString(response);
var jsonString = Y.JSON.stringify(response);
var path = Y.one('#txtRootPath').get('value');
var obj = eval("(" + jsonString + ")");
Expand Down
7 changes: 6 additions & 1 deletion src/com/taobao/rigel/rap/mock/service/impl/MockMgrImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,12 @@ private String mockValue(Parameter para, int index) {
}

private String mockjsValue(Parameter para, int index) {
String[] tags = para.getMockDataTEMP().split(";");
String mockData = para.getMockDataTEMP();
String[] tags = mockData.split(";");
if (mockData.contains("@mock=")) {
tags = new String[1];
tags[0] = mockData.substring(mockData.indexOf("@mock="));
}
boolean escape = true;
Map<String, String> tagMap = new HashMap<String, String>();
parseTags(tags, tagMap, true);
Expand Down

0 comments on commit 864de58

Please sign in to comment.