dnslabel

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package dnslabel converts arbitrary strings into DNS-safe label format (RFC 1123). It has no dependencies on the CEL or Go template engines so it can be shared by both without creating an import cycle.

Index

Constants

View Source
const MaxLabelLength = 63

MaxLabelLength is the maximum length of a DNS label per RFC 1123.

Variables

This section is empty.

Functions

func Slugify

func Slugify(s string) string

Slugify converts an arbitrary string into a DNS-safe label (RFC 1123).

The transformation:

  1. Converts to lowercase
  2. Replaces any character not in [a-z0-9-] with a hyphen
  3. Collapses consecutive hyphens into a single hyphen
  4. Strips leading and trailing hyphens
  5. Truncates to 63 characters (the DNS label limit)
  6. Strips any trailing hyphen introduced by truncation

Returns an empty string if the input is empty or contains no valid characters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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