Skip to content
  • Home
  • About
  • Legal
  • Privacy
nocin.eu
nocin.eu
Homelab, Linux & ABAP (~˘▾˘)~
 
  • Home
  • About
  • Legal
  • Privacy
Home Posts tagged "url"

Tag: url

JavaScript

[JavaScript] Extract hostname from string

February 17, 2021 February 17, 2021  ES6, hostname, JavaScript, string, url

https://stackoverflow.com/questions/8498592/extract-hostname-name-from-string

const getHostname = (url) => {
  // use URL constructor and return hostname
  return new URL(url).hostname;
}

let hostname = getHostname("https://google.com");
console.log(hostname); //google.com

This site is best viewed using Dark Reader! 🙂

Categories

open all | close all

Archives

  • March 2021 (1)
  • February 2021 (12)
  • January 2021 (14)
  • December 2020 (8)
  • November 2020 (10)
  • October 2020 (5)
  • September 2020 (5)
  • August 2020 (5)
  • July 2020 (6)
  • June 2020 (2)
  • May 2020 (11)
  • April 2020 (6)
  • March 2020 (6)
  • February 2020 (13)
  • January 2020 (6)
  • December 2019 (7)
  • November 2019 (11)
  • October 2019 (11)
  • September 2019 (31)
  • August 2019 (30)

RSS nocin.eu

  • [JavaScript] APIs and Microservices Projects
  • [ABAP] Report Template
  • [VSC] Extensions
  • [JavaScript] Style Guides
  • [JavaScript] Extract hostname from string
Back to Top
MastodonXingLinkedIn
2020 nocin.eu
Legal
Privacy
Powered by Fluida & WordPress.