ufnet

package
v0.23.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package ufnet contains utilities for domain and hostname parsing/validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHostname

func ExtractHostname(url string) (hostname string)

ExtractHostname quickly retrieves hostname from the given URL.

NOTE: ExtractHostname is an optimized, best-effort function to retrieve a hostname from a URL-like string. The result is not guaranteed to be correct for some edge cases, which include non-hierarchical URLs and IPv6 hostnames.

TODO(a.garipov): Consider moving to golibs.

TODO(s.chzhen): Consider using url.URL.

func IsDomainName

func IsDomainName(name string) (ok bool)

IsDomainName checks if the given string is a valid domain name. Valid domain name has the following syntax: [label.]... label.label. Each label is 1 to 63 characters long, and may contain:

  • ASCII letters a-z and A-Z,
  • digits 0-9,
  • hyphen ('-').

Labels cannot start or end with hyphens (RFC 952). Max length of ASCII hostname including dots is 253 characters. TLD is greater or equal to 2 characters. TLD has "[a-zA-Z]+" or "xn--[a-zA-Z0-9]+" format.

TODO(s.chzhen): Consider using netutil.IsValidHostname. TODO(d.kolyshev): Consider moving to golibs.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL