Open infogulch opened 3 days ago
Hi @infogulch
I think cou can use one line string and multi line string even if they're not body
https://hurl.dev/docs/request.html#oneline-string-body
POST https://example.org/helloworld
`Hello world!`
You can try, it may works in predicate
Unfortunately it doesn't work:
error: Parsing predicate value
--> /home/joe/xtemplate/test/tests/nats.hurl:11:15
|
11 | body contains `data: "<li>hello 1</li>"\n\n`
| ^ invalid predicate value
|
Other variations I tried:
body contains `data: "<li>hello 1</li>"` i.e. no trailing \n\n
body contains ```data: "<li>hello 1</li>"```
body contains ```
data: "<li>hello 1</li>"
```
I think backticks would be fine to use instead of single quotes if you want to keep the syntax consistent. Multiline would be nice as well.
Thanks @infogulch I was pretty sure this could work. I think we'll implement support for single and triple backticks.
Problem to solve
Sometimes when asserting a response I want to match body or query contents that themselves contain quotes so they must be escaped. This is annoying to do, but also makes it hard to read.
Proposal
It would be nice if hurl could parse strings with alternate quotes so other quote types would not need to be escaped.
Additional context and resources
Example output of what happens if you try to use single quotes in the way I described above today:
Tasks to complete