-
Notifications
You must be signed in to change notification settings - Fork 42
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
remove "uses_netloc" parameter and attribute to .__init__ and .replace #24
Comments
WHATWG and 3986 love to avoid talking about the slashes, but I don't know what to call them other than "netloc slashes", and Naming aside, In those cases, as mentioned in #23, If we switched to an object-based |
WHATWG doesn't care much about the slashes since they're just "the things that come after http://" :) but 3986 specifically documents them; they are the slashes that come before the authority. Which… actually raises the question. They always and only come before the authority. The scheme attribute is just whether or not it has an authority. Which is just a validation thing: the selected scheme should be able to prevent you from using an authority, but the information about the scheme isn't necessary past that point. So the attribute seems like it ought to be useless. In fact, reading the implementation alerted me that there's a bug in this area (another failed >>> URL().replace(scheme=u'http', path=[u'',u'',u'google.com'])
URL.from_text(u'http://google.com') |
(My thinking on that particular bug is that |
Haha, bravo, that's a good one! One question that's been on my mind from the start is: what is the goal of the
Because But now we're definitely in 2 verging on 3. If that's the goal, then there's a lot of parsing logic spread around (e.g., in |
Are 2 and 3 meaningfully different? |
In other cases I might be swayed that |
So I think it's becoming clear that http://fsharpforfunandprofit.com/posts/designing-with-types-making-illegal-states-unrepresentable/ is |
2 and 3 are of course different, as you've shown in your case! You constructed a valid URL through creative means. |
Oh, I see what you mean. I would just consider it an "invalid" URL if it doesn't have a string representation, so I'd say both 2&3 :) |
I think I'm going to close this, because #112 deals with the practical problem here, as well as updating the documentation to avoid making the mistake of calling the path portion of |
In twisted.python.url I tried very hard to eliminate the use of the confusing, vague, and antiquated term "netloc". (NB: neither https://tools.ietf.org/html/rfc3986 nor https://url.spec.whatwg.org includes the string "netloc"). I would therefore like to eliminate its use in
uses_netloc
as well.uses_netloc
describes an attribute of a scheme. However, in its current incarnation it can be made nonsensically inconsistent with the scheme it's actually using. Additionally, schemes also have other attributes, such as a name, and a default port number. (Possibly more in the future?) As such, the presence of the scheme registry makes URL objects kinda/sorta mutable after the fact.My suggestion for a replacement would be for
URL
to reference a structuredscheme
object; the external scheme registry could then be a collection of such objects. If a URL is created before the registry is populated, its scheme object could then be inconsistent with the global one, but it could be replaced. At this point, I believe schemes would just have the three attributes given above (i.e. the parameters toregisterScheme
.The text was updated successfully, but these errors were encountered: