0

I'm parsing a URL in javascript to use the subdomain as a variable.

window.location.href.split("/")[2].split(".")[0];

However, I need to remove/bypass the WWW when it's in the subdomain, how can this be done?

Example: http://sub.domain.com (works) http://www.sub.domain.com (gets www instead of the "sub")

I greatly appreciate the assistance! Thanks

1 Answers1

2

Try removing www. before

window.location.href.replace("www.","").split("/")[2].split(".")[0];