javascript

Domain Name From URL

Get domain name from URL using JavaScript

Edson Frainlar
Edson FrainlarSeptember 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};

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


Edson Frainlar

Written byEdson Frainlar
Mission-driven Full-stack Developer with a passion for developing KTern, Dev Collaboration, and teaching. Curious to explore Quantum Information and Computing.
Connect

Is this page helpful?

Related ArticlesView All

Related VideosView All

Easy NPM Package Updates with Yarn Upgrade Interactive

The Async Await Episode I Promised