问题
I am tring to escape some values in a path.
Let's say I'm trying to obtain https://www.google.com/https%3A%2F%2Fdomain
I've tried the following options :
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
But I obtain
https://www.google.com/https://domain
https://www.google.com/https://domain
https://www.google.com/https%253A%252F%252Fdomain
Why is \
not working, while %2F
is being escaped into %252F
?
回答1:
Encoding is the correct behavior: https://www.w3schools.com/tags/ref_urlencode.asp
But your workaround for this un-usual URL is in Karate make it as part of the url
itself:
Given url 'https://httpbin.org/https%3A%2F%2Fdomain'
When method get
Then status 200
来源:https://stackoverflow.com/questions/54476369/cannot-escape-url-as-needed