【发布时间】:2022-01-21 19:14:40
【问题描述】:
我有一个以下模式的 URL (GET REQUEST)
- ^/testpath/1/test?pathid=1
- ^/testpath/1/test?pathid=1,2
- ^/testpath/1/test?pathid=1,2,5
其中 pathid 查询字符串参数以逗号分隔
我有以下粗短的映射来匹配这些 url 模式
- request:
url: ^/testpath/(.*)/test
query:
pathid: '1'
method: GET
response:
headers:
Content-Type: application/json
status: 200
file: response/path-1.json
- request:
url: ^/testpath/(.*)/test
query:
pathid: '1,2'
method: GET
response:
headers:
Content-Type: application/json
status: 200
file: response/path-2.json
- request:
url: ^/testpath/(.*)/test
query:
pathid: '1,2,5'
method: GET
response:
headers:
Content-Type: application/json
status: 200
file: response/path-3.json
但我无法让此 URL 映射根据不同的参数组合正确传递不同的有效负载。
- 1 -> 有效载荷1
- 1,2 -> 有效载荷2
- 1,2,5 -> 有效载荷3
如何做到这一点?
【问题讨论】:
-
您可能希望在您的正则表达式末尾结束
$,否则它们可能会产生意想不到的结果... -
也试过了,但没有成功。
标签: javascript node.js stubbing stubby4j stubby4node