Domain Name From URL

Get domain name from URL using JavaScript

Abhith RajanSeptember 13, 2020 · 1 min read · Last Updated:
1export const domainFromURL = (url) => {
2 return url
3 .replace("http://", "")
4 .replace("https://", "")
5 .replace("www.", "")
6 .split(/[/?#]/)[0];

Written by Abhith Rajan
Abhith Rajan is an aspiring software engineer with more than 8 years of experience and proven successful track record of delivering technology-based products and services.
Buy me a coffee

Was this helpful?

Show some ❤️

Share this page on Twitter to appear on the webmentions* 💡

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub

Related VideosView All

The Async Await Episode I Promised

Related StoriesView All