我想逃避路径中的某些值。
假设我正在尝试获取https://www.google.com/https%3A%2F%2Fdomain
我尝试了以下选项:
Scenario: escape value
* url "https://www.google.com"
* path "https://domain"
When method get
* path "https\:\/\/domain"
When method get
* path "https%3A%2F%2Fdomain"
When method get
* path "https\\:\\/\\/domain"
When method get
但是我得到
https://www.google.com/https://domain
https://www.google.com/https://domain
https://www.google.com/https%253A%252F%252Fdomain
\
被转义为%2F
时,为什么%252F
不起作用?
答案 0 :(得分:2)
编码是正确的行为:https://www.w3schools.com/tags/ref_urlencode.asp
但是,您可以在Karate中使用此异常URL来解决此问题,使其成为url
本身的一部分:
Given url 'https://httpbin.org/https%3A%2F%2Fdomain'
When method get
Then status 200