Quantcast
Viewing latest article 4
Browse Latest Browse All 4

Answer by Ooker for Is it possible to use .contains() in a switch statement?

Try the tldts library:

npm i tldts
import { parse } from "tldts";const domainWithoutSuffix = parse(href).domainWithoutSuffix;switch (domainWithoutSuffix) {  case "facebook":    // do stuff  case "github":    // do stuff  case "youtube":    // do stuff  default:    // do stuff}

Viewing latest article 4
Browse Latest Browse All 4

Trending Articles