javascript

Domain Name From URL

Get domain name from URL using JavaScript

Abhith Rajan
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];
7};

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

Was this helpful?

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

Related ArticlesView All

Related VideosView All

Easy NPM Package Updates with Yarn Upgrade Interactive

The Async Await Episode I Promised

Related StoriesView All