fsname

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fsname sanitizes arbitrary (including Cyrillic) strings into safe filesystem path segments and file name stems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileStem

func FileStem(raw, fallback string) string

FileStem turns an uploaded file's name into a URL-friendly stem: transliteration, lower case and whitespace → "-": "My Poster.JPG" → "my-poster". The extension is dropped; fallback is returned when nothing usable remains.

func NormalizeFolderSegment

func NormalizeFolderSegment(raw string) string

NormalizeFolderSegment transliterates Cyrillic to Latin, maps spaces to underscores, keeps [a-z0-9_-], collapses repeats. Result length is capped at 64 characters.

func SanitizeImageStem

func SanitizeImageStem(raw string) string

SanitizeImageStem turns the original file base name into a safe stem for storage: transliterates Cyrillic, keeps ASCII letters (case preserved) and digits, allows _ and -; spaces become underscores; other runes become underscores; collapses repeats. Empty or invalid result becomes "image". Length is capped at 200 runes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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