[whatwg] [URL] Cargo-cult naming in URL and matching
Glenn Maynard
glenn at zewt.org
Fri Feb 8 07:03:39 PST 2013
On Fri, Feb 8, 2013 at 6:38 AM, Anne van Kesteren <annevk at 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
More information about the whatwg
mailing list