Documentation
¶
Index ¶
- func ExtToLang(ext string) string
- func GenerateID() (string, error)
- func GetEnv(key, fallback string) string
- func GetHighlightedPreview(content, query string) string
- func GetPreview(content string) string
- func IsValidID(id string) bool
- func LangToExt(lang string) string
- func NormalizeLanguage(language string) string
- func SanitizeTitle(title, fallback string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtToLang ¶
ExtToLang converts a file extension (e.g. ".py") to a language name (e.g. "python"). Returns "text" if the extension is not recognized.
func GenerateID ¶
GenerateID creates a cryptographically random six-character identifier.
func GetHighlightedPreview ¶
GetHighlightedPreview returns a plain-text preview snippet centered around the first match of query. The frontend is responsible for highlighting.
func GetPreview ¶
GetPreview returns a cleaned, truncated preview snippet of paste content for display in the sidebar. Returns plain text (no HTML escaping); the frontend is responsible for escaping before rendering.
func IsValidID ¶
IsValidID accepts a legacy six-character ID or a secure 32-character ID. Every character must be alphanumeric to prevent path traversal.
func LangToExt ¶
LangToExt converts a language name (e.g. "python") to its file extension (e.g. ".py"). Returns ".txt" if the language is not recognized.
func NormalizeLanguage ¶ added in v1.4.0
NormalizeLanguage returns a supported language name or text.
func SanitizeTitle ¶ added in v1.4.0
SanitizeTitle converts a title into a portable filename segment.
Types ¶
This section is empty.