Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url encoding functions #1982

Closed
nyurik opened this issue Mar 29, 2024 · 5 comments
Closed

Add url encoding functions #1982

nyurik opened this issue Mar 29, 2024 · 5 comments

Comments

@nyurik
Copy link
Contributor

nyurik commented Mar 29, 2024

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
Copy link
Owner

casey commented Mar 29, 2024

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
Copy link
Contributor

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

  • percent-encoding some characters, like Javascript encodeURI
  • percent-encoding most characters, notably including characters that have meaning in a URL, like Javascript encodeURIComponent
  • the encoding that replaces some whitespace characters with + and does percent-encoding in some other cases, like seen in search engine search URLs
  • base64
  • ...

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

@nyurik
Copy link
Contributor Author

nyurik commented Mar 29, 2024

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)

@laniakea64
Copy link
Contributor

Now that #2052 has been merged and is available in latest just release, should this issue be closed?

@casey
Copy link
Owner

casey commented Jun 5, 2024

Yup, thanks for noticing!

@casey casey closed this as completed Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants