Cannot escape url as needed

微笑、不失礼 提交于 2019-12-20 04:14:04

问题


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

  1. https://www.google.com/https://domain
  2. https://www.google.com/https://domain
  3. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!