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

On Wednesday 02 November 2016 08:19:05 Anne van Kesteren wrote:
> There's no way to parse a relative URL (without a base URL) so I'm not
> sure how that makes sense.

Leaving protocol-relative out of the discussion for clarity, this would 
be the constructor in pseudo:

    if not has_scheme(url)
        url = IFace.make_fully_qualified_url(url)
    
    parse(url)

It can become smarter if one wants to pass the URL object in a 
preliminary state and make getters/setters verify whether parsing is 
finished, but the procedure remains:

1. Determine whether we have all the info
2. If needed, request needed info from the object adhering to the 
interface
3. Finish parsing with complete info

Maybe you should clarify which cases you are thinking of that make you 
say "no way to parse without base URL", because I can make or find a 
parser that extracts path components just fine from a given string.
I can also determine if a scheme is present, since spec provides a max 
length before which a scheme terminating column must occur and a limited 
character set for the scheme.
-- 
Melvyn Sopacua


-- 
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-257913050

Received on Wednesday, 2 November 2016 16:10:30 UTC