I have domain name for eq.
1) http://www.abc.com/search 2) http://go.abc.com/work
I get only domain name from the above URL
Output
You can do this with plain js by using
location.host
document.location.hostname