UNPKG

@nire0510/wmcli

Version:

Useful tools for webmasters

18 lines (13 loc) 394 B
import commander from 'commander'; export function isHostname(input: string): string { if (!/^\w+\.\w+(\.\w+)?(\.\w+)?$/.test(input)) { throw new commander.InvalidOptionArgumentError('Not a valid hostname, e.g. google.com'); } return input; } export function isUrl(input: string): string { if (!/^https?:\/\//.test(input)) { return `https://${input}`; } return input; }