Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

karate - Cannot escape url as needed

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...