Skip to main content
Glama
Southclaws

Storyden

by Southclaws
slugify.go1.04 kB
package mark import ( "regexp" "strings" "golang.org/x/text/unicode/norm" ) // Matches the TypeScript implementation in web/src/utils/slugify.ts var ( nonLetterNumberPattern = regexp.MustCompile(`[^\p{L}\p{M}\p{N}\-_]+`) multiHyphenPattern = regexp.MustCompile(`-+`) ) func Slugify(input string) string { // Trim leading and trailing whitespace trimmed := strings.TrimSpace(input) // NFKC normalization normalized := norm.NFKC.String(trimmed) // Lowercase lowercased := strings.ToLower(normalized) // Replace non-letter/number chars with hyphens lettersReplaced := nonLetterNumberPattern.ReplaceAllString(lowercased, "-") // Collapse multiple hyphens collapsed := multiHyphenPattern.ReplaceAllString(lettersReplaced, "-") // Trim leading and trailing hyphens/underscores trimmedDividers := strings.Trim(collapsed, "-_") return trimmedDividers } // IsSlug checks if a string is already a valid slug by comparing it to its slugified version func IsSlug(input string) bool { return Slugify(input) == input }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server