Documentation
¶
Overview ¶
Package hostnames composes and validates the DNS names served by servd.
Index ¶
- Constants
- func ApplyWorktreePrefix(base, prefix string) string
- func FormatURL(hostname string, port int, tls bool) string
- func ParseHostname(input, tld string) (string, error)
- func ParseHostnames(input string, tlds []string) ([]string, error)
- func SanitizeLabel(name string) string
- func TruncateLabel(label string) string
- func ValidateLabel(label string) error
- func ValidateTLD(tld string) error
- type InferredName
- type WorktreePrefix
Constants ¶
const MaxDNSLabelLength = 63
MaxDNSLabelLength is the RFC 1035 maximum length of one DNS label.
Variables ¶
This section is empty.
Functions ¶
func ApplyWorktreePrefix ¶
ApplyWorktreePrefix prepends prefix as a DNS label when it is non-empty.
func ParseHostname ¶
ParseHostname normalizes input as a subdomain of tld and validates the full resulting hostname.
func ParseHostnames ¶
ParseHostnames normalizes input for each configured TLD. If input already ends with a configured TLD, the longest matching suffix is stripped first. Invalid TLD-specific results are skipped while valid results are retained.
func SanitizeLabel ¶
SanitizeLabel converts a name into one valid DNS label. It lowercases, replaces invalid characters with hyphens, collapses repeated hyphens, and truncates labels that exceed the DNS limit.
func TruncateLabel ¶
TruncateLabel keeps a DNS label within MaxDNSLabelLength. Truncated labels end with a deterministic six-character SHA-256 suffix to retain uniqueness.
func ValidateTLD ¶
ValidateTLD verifies an explicitly configured DNS suffix.
Types ¶
type InferredName ¶
InferredName records a project name and the source from which it was inferred.
func InferProjectName ¶
func InferProjectName(cwd string) (InferredName, error)
InferProjectName finds a usable project name from the nearest package.json, then the Git repository root, then the current directory name.
type WorktreePrefix ¶
WorktreePrefix records the branch-derived prefix for a linked Git worktree.
func DetectWorktreePrefix ¶
func DetectWorktreePrefix(cwd string) (WorktreePrefix, error)
DetectWorktreePrefix returns a prefix for a linked worktree's non-default branch. The main checkout is never prefixed, even when it is on a feature branch. Default branches main and master are not prefixed.