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

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

From: Glenn Maynard <glenn@zewt.org>
Date: Fri, 8 Feb 2013 09:03:39 -0600
Message-ID: <CABirCh-g8hF7872XF=-=Nif5W8TcKuD8F9VZpDFQ=21XtK4Dbg@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: whatwg <whatwg@lists.whatwg.org>, Jake Archibald <jakearchibald@google.com>, Alex Russell <slightlyoff@google.com>
On Fri, Feb 8, 2013 at 6:38 AM, Anne van Kesteren <annevk@annevk.nl> wrote:

> I've been thinking of URL.compare(url, options) where in options you
> can say to ignore certain components and maybe additionally a way so
> you can normalize away percent-encoding for some cases as the parser
> does not do that. Thus far you're the only one who seems to be
> requesting this feature. I haven't really figured out a way to
> quantify demand somehow.
>

A compare method is probably useful, since you'd also want case-insensitive
comparisons for some parts and not others (eg. lowercase protocol and host
before comparing).  Comparing only certain components doesn't seem very
common, though, and simple for people to do themselves:

function get_url_path(url)
{
    url = new URL(url);
    url.search = "";
    url.hash = "";
    return url;
}

if(get_url_path(url1).toString() == get_url_path(url2).toString())
    ;

-- 
Glenn Maynard
Received on Friday, 8 February 2013 15:04:07 UTC

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