Compare commits

...

3 Commits

Author SHA1 Message Date
jmiller 8ffdbff72a Merge pull request 'fix: preserve + and . in wiki slugs' (#218) from fix/wiki-slug-polish into dev
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
PR RC Release / Build RC Release (pull_request) Successful in 21s
2026-05-26 18:48:06 +00:00
Jonathan Miller d609b8db8c fix: preserve + and . in wiki slugs, clean stray plus signs
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
PR RC Release / Build RC Release (pull_request) Successful in 1s
Allow C++, .NET, version numbers (2.0.1) in wiki filenames.
Clean up isolated plus signs that appear between hyphens.

Examples:
- C++ vs C# -> C++-vs-C.md
- .NET Guide -> .NET-Guide.md
- version 2.0.1 -> version-2.0.1-release.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-26 13:47:59 -05:00
jmiller bf35e5510d Merge pull request 'fix: unused import in require2fa.go' (#216) from fix/require2fa-import into dev 2026-05-26 18:39:22 +00:00
+5 -3
View File
@@ -150,16 +150,18 @@ func WebPathFromRequest(s string) WebPath {
}
var multiHyphenRe = regexp.MustCompile(`-{2,}`)
var nonAlphanumRe = regexp.MustCompile(`[^a-zA-Z0-9\-]`)
var nonSlugRe = regexp.MustCompile(`[^a-zA-Z0-9+.\-]`)
// sanitizeWikiTitle converts a user-provided title into a clean, URL-friendly slug.
// Spaces and special characters become hyphens, consecutive hyphens collapse to one.
// Preserves: letters, digits, hyphens, plus signs (+), and dots (.)
func sanitizeWikiTitle(title string) string {
title = strings.TrimSpace(title)
title = strings.ReplaceAll(title, " ", "-")
title = nonAlphanumRe.ReplaceAllString(title, "-")
title = nonSlugRe.ReplaceAllString(title, "-")
title = multiHyphenRe.ReplaceAllString(title, "-")
title = strings.Trim(title, "-")
title = strings.NewReplacer("-+-", "-", "+-", "-", "-+", "-").Replace(title) // clean stray plus signs
title = strings.Trim(title, "-+.")
return title
}