Skip to content

Commit

Permalink
feat: Closes #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbin committed Nov 7, 2018
1 parent 2005d8f commit 10c7899
Show file tree
Hide file tree
Showing 10 changed files with 1,104 additions and 58 deletions.
8 changes: 8 additions & 0 deletions lib/RESTAPIMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,18 @@ function RESTAPIMock(myURL, searchParams, callbackName) {
if (!option) {
return;
}
if (!option.request || !option.request.queries || Object.entries(option.request.queries).every(query => query[1] === searchParams.get(query[0]))) {
response = createRes(callbackName, option);
return true;
}
if (option.request) {
return false;
}
if (!option.needPars || searchParams.get(option.needPars)) {
response = createRes(callbackName, option);
return true;
}

} else {
if (!RESTAPI.needPars || searchParams.get(RESTAPI.needPars)) {
response = createRes(callbackName, RESTAPI);
Expand Down
2 changes: 1 addition & 1 deletion lib/anyproxy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function () {
const myURL = removeProtocal(URLO.href);
// console.log(URLO.searchParams);
const searchParams = URLO.searchParams;
const callback = searchParams.get('callback') || new URLSearchParams(requestDetail.requestData).get('callback');
const callback = searchParams.get('callback') || new URLSearchParams(requestDetail.requestData.toString()).get('callback');

const chain = [RESTAPIMock, fileMock];

Expand Down
6 changes: 3 additions & 3 deletions mock/RESTAPI.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
{
"URL": "//i.vip.iqiyi.com/client/store/pc/checkout.action",
"OPTIONS": ["gold", "diamond"],
"choices": ["diamond"]
"OPTIONS": ["gold", "diamondNotLogin", "diamond"],
"choices": ["diamond", "diamondNotLogin"]
},
{
"URL": "//i.vip.iqiyi.com/order/queryOrderStat.action",
Expand All @@ -33,7 +33,7 @@
},
{
"URL": "//passport.iqiyi.com/apis/user/info/queryWithVerify.action",
"choices": 1
"choices": 0
}
]
}
526 changes: 524 additions & 2 deletions mock/RESTAPI.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mock/filemap.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"disabled": false,
"disabled": true,
"map": {
"//static.iqiyi.com/js/qiyiVipPay/entry-vipPay": "./build/entry-vipPay.js",
"//static.iqiyi.com/js/qiyiVipPay/entry-bankcardPay": "./build/entry-bankcardPay.js",
Expand Down
Loading

0 comments on commit 10c7899

Please sign in to comment.