我正在使用Jest测试对包含西里尔字符的URL的GET请求,但它给出了以下错误:
#10 13.98 TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
#10 13.98
#10 13.98 at Test.request (node_modules/superagent/src/node/index.js:785:18)
#10 13.98 at Test.Object.<anonymous>.Request.end (node_modules/superagent/src/node/index.js:949:8)
#10 13.98 at Test.end (node_modules/supertest/lib/test.js:153:7)
#10 13.98 at node_modules/superagent/src/request-base.js:311:12
#10 13.98 at Test.Object.<anonymous>.RequestBase.then (node_modules/superagent/src/request-base.js:293:31)
#10 13.98 我的代码是:
const response = await request.get("hааy.com").expect(200);其中a是西里尔字母。有什么想法吗?
发布于 2021-06-28 17:30:47
如果将来有人遇到这个问题,我通过以下操作修复了这个问题:
const response = await request.get(encodeURI("h"+"\u0430"+"ay.com")).expect(200);https://stackoverflow.com/questions/68158981
复制相似问题