Get URL parts without regex
Here is a neat trick I found on Stackoverflow to get parts of any URL without using regex:
var a = document.createElement('a');
a.href = url;
// Get parts easily now:
console.log(a.host);
console.log(a.hostname);
// and so on...
Written by Kushagra Gour
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Parse
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#