W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2013

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

From: Alex Russell <slightlyoff@google.com>
Date: Fri, 8 Feb 2013 04:11:24 -0800
Message-ID: <CANr5HFWtknWqK1z0zOx-ZY3wbGUjPXyxQOg8U7wORQDrRXK6nA@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: whatwg <whatwg@lists.whatwg.org>, Jake Archibald <jakearchibald@google.com>
On Thursday, February 7, 2013, Anne van Kesteren wrote:

> On Thu, Feb 7, 2013 at 5:16 PM, Alex Russell <slightlyoff@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.
Received on Friday, 8 February 2013 12:11:51 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:19 UTC