mistweaverco/kulala.nvim

variable output gets wrapped inside quotes

yujinyuz opened this issue · 2 comments

I was trying out an endpoint. Here's the HTTP file that replicates the same thing.

@token="-6TyNIVowvCXdUpBZWNHfmAtQ8dMpcxmLKnOlNWrtgp06yYSBpfBbX88ggLd4kGmvQqUaQk7YtdCcBYgBX1Xxg"

###
POST https://httpbin.org/post
Authorization: Bearer {{AUTH_TOKEN}}
content-type: application/json

I'm always getting bad credentials when I place it inside Authorization: Bearer {{token}}

But other tools work properly. When I ran require('kulala').copy() this is what I got

curl -s -X 'POST' -H 'authorization:Bearer "-6TyNIVowvCXdUpBZWNHfmAtQ8dMpcxmLKnOlNWrtgp06yYSBpfBbX88ggLd4kGmvQqUaQk7YtdCcBYgBX1Xxg"' -H 'content-type:application/json' -A 'kulala.nvim/3.0.1' 'https://httpbin.org/post'

Manually removing the quotes makes the request successful.

Is there a reason why this is being wrapped in quotes? An observation I had with browsers copy as curl command do not include quotes ".

Yes, maybe the docs are still not very clear about this. This is because we will literally take ANYTHING after the = as value here.

So you if you write @gorilla="loves bananas" the variable {{gorilla}} literally means "loves bananas" if you write it this way:

@gorilla=loves bananas the variable {{gorilla}} means loves bananas.

In the v1.0.0 release of kulala, you had to put these variables that are string in quotes, but that isn't the case anymore. We literally take anything that comes after the = as value.

@gorillamoe
Oh that makes sense.

I removed the quotes and everything seems to work fine now

Thanks! Will close this issue