-
Notifications
You must be signed in to change notification settings - Fork 476
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
URI.js expects users to do their own URI-encoding, thus defeating its own purpose #79
Comments
What do you suggest we do about this then? |
Yeah, I deliberately stopped short of proposing a specific solution because I’m aware of the problem you point out, and I didn’t want to distract from the broader point. In fact One possible solution is to acknowledge that just as a URI is a data structure, so many URI components are themselves data structures and should be treated as such. So, for instance, Another solution is to do something similar to what you’ve done for query parameters. The |
I think we can leave That just leaves the problem of backward-compatibility. I do not want to add another (boolean) parameter to the signature. So we'd probably be left with exposing a new method. Ideas for a name? |
I can’t think of a name that adequately describes the difference without being excessively long, but if you marked |
I don't want to deprecate So, I'd propose we do the same thing to |
That sounds like a sensible idea as long as it’s a property of the URI instance and not set globally for the whole library... |
If we follow the example given, it is both. the global setting by default, but definable on instance-level. So this will be it then :) |
I will just have to hope that nobody uses the global version and breaks unrelated code from a distance :). |
I’m happy to have a go at implementing this on Monday unless you’d rather do it? Let me know :). |
sure, go ahead! I won't be doing any coding / merging until May, though. |
@djcsdy are you still on this? |
I've fixed this in master - it will be included in the next release. thank you for your help! the new method is called |
This makes me want to cry.
The whole point of having a library to handle URIs is that the user of the library shouldn’t have to think about how to encode or decode URIs.
For example, if I know that there is a resource called “Business Plan (90%)” in a directory called “My Extremely Dull Documents”, I ought be able to create a relative URI referencing that resource with syntax somewhat like this:
which would then produce a URI whose text representation is:
My%20Extremely%20Dull%20Documents/Business%20Plan%20%2890%25%29
.Similarly when parsing the resulting URI I ought to be able to do something somewhat like:
And get back the original strings:
["My Extremely Dull Documents"], ["Business Plan (90%)"]
.I know I can use
URI.encode
andURI.decode
on the path segments, but that requires the user to remember to do so, and to know and remember which of the several encoding schemes are used for which parts of the URI, so that’s pretty error-prone :(.The text was updated successfully, but these errors were encountered: