vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

Added support for percent-encoding variables when referenced

Open kibiz0r opened this issue 4 years ago • 1 comments

Problem

This almost certainly doesn't do what you want, because the & will not get percent-encoded:

@name = Strunk & White

GET https://{{host}}/authors/{{name}}

However, we can't assume we should always percent-encode the value of a variable.

So we need some sort of helper.

Proposed Solution

New syntax for referencing a file variable: {{%foo}} This tells us to percent-encode the value.

Example:

@name = Strunk & White

GET https://{{host}}/authors/{{%name}}

kibiz0r avatar Nov 18 '21 17:11 kibiz0r

@Huachao Any thoughts?

kibiz0r avatar May 06 '22 14:05 kibiz0r

@Huachao I support adding this functionality! Very useful when getting tokens from a response that contains characters that require escaping.

@someparam = abcd&efgh
GET https://localhost/abc?p={{%someparam}}

pfzim avatar Dec 14 '22 05:12 pfzim

@kibiz0r Merged, thanks. And it will be published in the next release

Huachao avatar Jul 19 '23 08:07 Huachao