casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
17.6k stars 399 forks source link

Add url encoding functions #1982

Open nyurik opened 1 month ago

nyurik commented 1 month ago

I was trying to use curl from just:

upload credentials file:
   curl '-u{{credentials}}' -T {{quote(file)}} 'https://example.com/foo/bar/{{file_name(file)}}'

and this worked fine until the filename had a # character - which broke the above because i was not URL-encoding it. I think just could use a url encoding function to handle such cases

casey commented 1 month ago

Seems reasonable to me! Maybe url_encode(STRING). This would make a great first PR for anyone who wants to take a crack at it.

laniakea64 commented 1 month ago

"URL encoding" can have several different meanings, e.g.

Guessing from the example case, you're seeking encodeURIComponent-like encoding?

nyurik commented 1 month ago

agree, url encoding has a number of different usecases, so it might be useful to provide more than one function. For my usecase, encodeURIComponent is enough. I do not know how common are other usecases - I haven't encountered them (yet)