transform

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package transform provides string and data transformation utilities such as slugifying strings for URL-friendly formats.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Slugify

func Slugify(s string) string

Slugify converts a string to a URL-friendly slug matching Zod v4's slugify behavior:

  1. Lowercase the input
  2. Trim whitespace
  3. Remove non-word, non-space, non-hyphen characters
  4. Collapse consecutive whitespace, underscores, and hyphens into a single hyphen
  5. Trim leading and trailing hyphens
Example
fmt.Println(Slugify("Hello World"))
fmt.Println(Slugify("  Multiple   Spaces  "))
fmt.Println(Slugify("Under_Score_And-Hyphens"))
Output:
hello-world
multiple-spaces
under-score-and-hyphens

Types

This section is empty.

Jump to

Keyboard shortcuts

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