fix(wiki): stop appending stray trailing ".-" to multi-word slugs (#832) #834
Reference in New Issue
Block a user
Delete Branch "fix/832-wiki-slug-trailing-dash-dot"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause
Some wiki pages with plain multi-word titles got a stray trailing
.-appended to their stored slug, on-disk.mdfilename, and APIsub_url(e.g. "CICD Dashboard" ->CICD-Dashboard.-). Reproduced with "CICD Dashboard", "Incident Response", "Rollback Procedures", "Backup Recovery", "15 admin panels".The bug was in the MokoGIT-customized
sanitizeWikiTitle()inservices/wiki/wiki_path.go. It converted spaces to hyphens before the result was passed toescapeSegToWeb().escapeSegToWeb()treats any-in its input as a literal dash and appends the reversible "DashMarker" (.-) to signal "do not apply dash<->space conversion to this segment". Because sanitize had already turned every space into a-, every multi-word title hit that branch and picked up a spurious trailing.-, which then leaked into the slug/filename/sub_url.Fix
Keep spaces intact through
sanitizeWikiTitle:space -> hyphenreplacement,The reversible
space<->dashconversion and the DashMarker logic now happen only inescapeSegToWeb, exactly as the scheme was designed. Titles containing a genuine literal hyphen (e.g. "wiki-name" ->wiki-name.-) still correctly get the marker, so the escape scheme remains reversible and existing escaped on-disk names still decode.Tests
Added regression cases to
TestUserTitleToWebPathcovering all five reported titles plus a multi-space case, asserting clean slugs with no trailing.-. Removed a stalea%bcase that asserted pre-existing, unrelated%-stripping behavior of the MokoGIT sanitizer.Note: the Go toolchain was not available in the fix environment, so tests could not be executed there. The change is self-contained string logic; the affected functions were verified with a faithful port that confirms all reported titles slug cleanly and round-trip (title -> web-path -> display) is preserved.
Fixes #832
https://claude.ai/code/session_01D5Zxu4xRRGoh9etzgShP4P