2018-02-26 00:11:31 +00:00
|
|
|
const hostnameLengthRegex = /^.{0,32}$/
|
|
|
|
const hostnamePatternRegex = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/
|
|
|
|
|
2020-02-09 10:21:13 +00:00
|
|
|
export default function isHostname(hostname: string) {
|
2018-02-26 00:11:31 +00:00
|
|
|
return hostnameLengthRegex.test(hostname) && hostnamePatternRegex.test(hostname);
|
|
|
|
}
|