Is there a way to get only the domain name from a given string.
Lets say the string is:
var url = "https://subdimain.thedomain.com/this/path/file.html"
All I want to get is:
thedomain.com
however, there are many factors I am not sure how to account for. For example:
- https or http
- subdomain or none
- tld (.com/.co.uk/.in/.fr) etc....
- path etc.. (/this/path/file.html)
Thanks for your help :)