[whatwg] [URL] Cargo-cult naming in URL and matching

Alex Russell slightlyoff at google.com
Fri Feb 8 04:11:24 PST 2013


On Thursday, February 7, 2013, Anne van Kesteren wrote:

> On Thu, Feb 7, 2013 at 5:16 PM, Alex Russell <slightlyoff at google.com<javascript:;>>
> wrote:
> > It doesn't appear straightforward to test if two URL objects reference
> the
> > same path. The serialization algorithm has as flag for omitting the
> > fragment, but not the query. Is there something in the API that I'm
> missing
> > that would make this easier than custom-serializing 2 URLs to omit
> queries
> > and then test string equality?
>
> new URL(path, base).pathname == new URL(path2, base).pathname ought to
> work.
>

But if I've been vended a URL object from some API, I first have to compare
the bases. I'd like a way to ask something like "is the full URL
up-to-and-including this component the same?" E.g., if I have an API that's
handed two URLs (a and b), I'd like to be able to write something like:

    if (a.toString("path") == b.toString("path")) {
      ...
    }


> > The word "search" seems drived from window.location's use of that. Is it
> > only included for compat with window.location? if so, can we drop it and
> > spec window.location to use a subclass that provides it?
>
> It's used by <a>, <area>, Location, and WorkerLocation. I think we
> should just embrace that the string variant is named search
> personally.
>

I'm less fussed on this point, but I do think naming matters. If we can do
better, I think we should.



More information about the whatwg mailing list