mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
9 lines
328 B
TypeScript
9 lines
328 B
TypeScript
const hostnameLengthRegex = /^.{0,48}$/
|
|
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])$/
|
|
|
|
export default function isHostname(hostname: string) {
|
|
return (
|
|
hostnameLengthRegex.test(hostname) && hostnamePatternRegex.test(hostname)
|
|
)
|
|
}
|