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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encoding URL string in URL
#2618
Comments
There are two ways we can percent encode the plain URL from user input. Which would be the preferred method @s-ludwig ? |
Since paths in URLs can contain a slash as part of a path segment, we probably shouldn't do this in the canonical URL parser (e.g. I'd propose to add this as a prominent API function in addition to the usual URL constructor. The goal should be to be compliant with the WHATWG specification, but we can go there piece by piece. |
Constructing
URL
from plain URL string, likehttp://example.com/hello-馃實
orhttp://example.com/merhaba-d眉nya
, throws an exception with messageInvalid character in internet path.
.Currently the constructor expects percent encoded URL strings since
InetPath
validation expects percent encoded URL strings, which is consistent implementation withinInetPath
. But there is alsoSegment2
implementation inGenericPath
which can encode segments in path of the URL, soURL
constructor can provideInetPath
with encoded segments.Developers can still construct an
URL
by constructingInetPath
from percent encoded path segmentsSegment2
. But this can be overwhelming for developers. I think default expectation of the constructor should be plain URL for improving ease of use and developer experience.The text was updated successfully, but these errors were encountered: