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

Document that only query parameters are percent-encoded #43

Open
j-maas opened this issue Feb 10, 2021 · 1 comment · May be fixed by #44
Open

Document that only query parameters are percent-encoded #43

j-maas opened this issue Feb 10, 2021 · 1 comment · May be fixed by #44

Comments

@j-maas
Copy link

j-maas commented Feb 10, 2021

In light of the question of how URLs should be percent-encoded (#42), I think there is a more pressing underlying issue.

There is confusion about how Url.Builder and Url.Parser methods work, since the documentation on percentEncode makes it seem that functions like absolute, relative, and crossOrigin will also do percent-encoding on the paths, as evidenced by the top comment in #25.

To address the misunderstanding of what gets percent-encoded by those functions and how to achieve the desired behavior, we can change the documentation for percentEncode from

Use Url.Builder instead! Functions like absolute, relative, and crossOrigin already do this automatically! percentEncode is only available so that extremely custom cases are possible, if needed.

to something like

Use Url.Builder instead! Functions like absolute, relative, and crossOrigin already encode query parameters automatically! percentEncode is only available so that extremely custom cases are possible, if needed.

Note that these functions do not percent-encode path components, because not everyone needs the same encoding. If you need to do that, you need to call this function on each path, for example Url.Builder.absolute (List.map percentEncode ["encode me"]) [] to get /encode%20me.

Similarly, the documentation for percentDecode can be changed from

Use Url.Parser instead! It will decode query parameters appropriately already! percentDecode is only available so that extremely custom cases are possible, if needed.

to

Use Url.Parser instead! It will decode query parameters appropriately already! percentDecode is only available so that extremely custom cases are possible, if needed.

Note that Url.Parser does not percent-decode path components, because because not everyone needs the same encoding. If you need to do that, you can create a custom Url.Parser with custom "STRING" Url.percentDecode.

@evancz
Copy link
Member

evancz commented Feb 10, 2021

Can you turn this into a PR? I cannot promise that I'll use the exact text, but I think that'd be a better way to record this recommendation.

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

Successfully merging a pull request may close this issue.

2 participants