Re: [whatwg/dom] Consider adding document.parseURL(url) (#356)

I don't believe we need a parser, URL() should do that. We need a resolver.

How about this:

URL Object
URL(string url, URLResolverInterface Iface=<Implementation specific default object>)
Methods:
bool is_fully_qualified_url(): whether URL contains all information to establish a connection with the server (server being a broad term)
bool is_absolute(): whether URL contains all information to resolve the document path from the root node of the server
bool is_relative(): whether URL contains only parts that can be resolved using a related location

Note: Implementation specific default object should probably be window.location for the browser and that being the window that corresponds with the address bar. For authors it will then be transparent when they need to provide a different resolver.

URLResolverInterface:
string make_fully_qualified_url(): returns fully qualified URL
string make_absolute_url(): returns absolute URL

In the constructor of URL, it calls make_fully_qualified_url() on the provided object, either unconditionally or when it determines the URL is not fully qualified (implementer freedom).
Note that make_absolute_url() should be capable of both expanding a relative URL as well as reducing a fully qualified one.
Protocol-relative URL handling may be needed. I don't see the need for make_relative_url() but others might.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/356#issuecomment-257891678

Received on Wednesday, 2 November 2016 15:03:41 UTC