To extract the hostname portion of a URL, use the hostname method
Example
Live Demo
<!DOCTYPE html>
<html>
<body>
<script>
var url = new URL("https://example.com/asdf/asdf/sadf.aspx?blah");
document.write(url.hostname);
</script>
</body>
</html>