javascript

Domain Name From URL

Get domain name from URL using JavaScript

Tarun Sharma
Tarun SharmaSeptember 13, 2020 ยท 1 min read ยท Last Updated:
export const domainFromURL = (url) => {
  return url
    .replace("http://", "")
    .replace("https://", "")
    .replace("www.", "")
    .split(/[/?#]/)[0];
};

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


Tarun Sharma

Written byTarun Sharma
Tarun Sharma is a software engineer by day and a full-stack developer by night. He's coding for almost a decade now. He codes ๐Ÿง‘โ€๐Ÿ’ป, write โœ๏ธ, learn ๐Ÿ“– and advocate ๐Ÿ‘.
Connect

Is this page helpful?

Related ArticlesView All

Related VideosView All

Stack Overflow Clone - APIs Integration Redux Toolkit [Closure] - App Demo #05

Become Ninja Developer - API security Best Practices with Node JS Packages #15

Nest JS Microservices using HTTP Gateway and Redis Services (DEMO) #nestjs #microservices #16