【发布时间】:2018-03-01 16:50:26
【问题描述】:
我正在尝试模拟包含问号但不属于查询字符串的路径,例如:
https://example.com/index.php?/api/v2/get-item/1
Nock 在问号处分割路径,并希望我提供查询字符串键值对:
const scope = nock('https://example.com/index.php?/api/v2/get-item/')
.get('/1')
.reply(200, { item });
console.log(nock.activeMocks());
> [ 'GET https://example.com/index.php/1' ]
我已经尝试过对路径进行 URI 编码,但我仍然遇到同样的问题。这里最好的方法是什么?
【问题讨论】:
-
自己去掉问号。使用 String.replace。根据协议,此类 URL 无效。
-
URL 是第三方依赖。看看这里的文档:docs.gurock.com/testrail-api2/reference-suites我不知道这是一个 php 还是 testrail 的东西?
-
现有答案有帮助还是您仍需要帮助?
标签: javascript node.js nock