Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be an alternative for window.URL in IE?

I'm now using window.URL object to work with url:

var url = new window.URL(text);
return url.host + url.pathname;

but it looks like IE does not completely support it.

What universal solution could you recommend?

like image 610
Stepan Suvorov Avatar asked Mar 03 '16 09:03

Stepan Suvorov


2 Answers

I use parseURI.js by Steven Levithan: http://blog.stevenlevithan.com/archives/parseuri

It's small but comprehensive. To use it to do the same job as your snippet:

var url = parseUri(text);
return url.host + url.path;
like image 134
Euan Smith Avatar answered Oct 16 '22 19:10

Euan Smith


I use this one as a backup for IE, this is an implementation of w3c specs maintained by PolymerJS https://github.com/webcomponents/URL

like image 1
JR Utily Avatar answered Oct 16 '22 20:10

JR Utily