How to use the tlds.concat function in tlds

To help you get started, we’ve selected a few tlds examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lukechilds / my-name-is-url / src / regex.js View on Github external
import tlds from 'tlds';

// Reusables
const validTlds = tlds.concat(['local', 'dev']).join('|');
const escapeChar = `\\`;
const notWhitespaceCommaDoubleQuoteOrDot = `[^${escapeChar}s,"]`;
const dot = `${escapeChar}.`;
const hostnameChars = `[a-z0-9]`;
const number = `[0-9]`;
const endingChars = `${dot}?([${escapeChar}s<>",]|$)`;

// Sections
const optionalScheme = `(([a-z]+:)?//)?`;
const hostname = `(((${hostnameChars}-*)*${hostnameChars}+)${dot})+(${validTlds})`;
const ip = `(${number}{1,3}${dot}){3}${number}{1,3}`;
const optionalPortNumber = `(:${number}+)?`;
const optionalSlash = `(${escapeChar}/(${notWhitespaceCommaDoubleQuoteOrDot}*)?)?`;
const endsWithButDontMatch = `(?=${endingChars})`;

// Build

tlds

A list of TLDs.

MIT
Latest version published 1 month ago

Package Health Score

75 / 100
Full package analysis