fix(wiki): stop appending stray trailing ".-" to multi-word slugs (#832) #834

Merged
jmiller merged 1 commits from fix/832-wiki-slug-trailing-dash-dot into dev 2026-07-19 07:04:43 +00:00
Owner

Root cause

Some wiki pages with plain multi-word titles got a stray trailing .- appended to their stored slug, on-disk .md filename, and API sub_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() in services/wiki/wiki_path.go. It converted spaces to hyphens before the result was passed to escapeSegToWeb(). 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:

  • add space to the allowed-character regex sets,
  • remove the space -> hyphen replacement,
  • collapse runs of spaces to one,
  • trim spaces exposed after leading/trailing punctuation is stripped.

The reversible space<->dash conversion and the DashMarker logic now happen only in escapeSegToWeb, 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 TestUserTitleToWebPath covering all five reported titles plus a multi-space case, asserting clean slugs with no trailing .-. Removed a stale a%b case 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

## Root cause Some wiki pages with plain multi-word titles got a stray trailing `.-` appended to their stored slug, on-disk `.md` filename, and API `sub_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()` in `services/wiki/wiki_path.go`. It converted spaces to hyphens **before** the result was passed to `escapeSegToWeb()`. `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`: - add space to the allowed-character regex sets, - remove the `space -> hyphen` replacement, - collapse runs of spaces to one, - trim spaces exposed after leading/trailing punctuation is stripped. The reversible `space<->dash` conversion and the DashMarker logic now happen only in `escapeSegToWeb`, 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 `TestUserTitleToWebPath` covering all five reported titles plus a multi-space case, asserting clean slugs with no trailing `.-`. Removed a stale `a%b` case 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
jmiller added 1 commit 2026-07-19 06:53:16 +00:00
fix(wiki): stop appending stray trailing ".-" to multi-word slugs
Generic: Project CI / Lint & Validate (pull_request) Successful in 36s
Generic: Project CI / Tests (pull_request) Successful in 32s
Universal: PR Check / Require Docs Update (pull_request) Has been skipped
Universal: PR Check / Wiki Update Reminder (pull_request) Has been skipped
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Validate PR (pull_request) Successful in 7s
Universal: PR Check / Secret Scan (pull_request) Successful in 1m58s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
RC Revert / Rename rc/ back to dev/ (pull_request) Has been cancelled
e69eeb1d6e
Fixes #832.

Root cause: the MokoGIT-customized sanitizeWikiTitle() in
services/wiki/wiki_path.go converted spaces to hyphens BEFORE the result
was handed to escapeSegToWeb(). escapeSegToWeb() treats any "-" in its
input as a *literal* dash and appends the reversible "DashMarker" (".-")
to disable dash<->space round-tripping. Because sanitize had already
turned every space into a dash, every multi-word title tripped that
branch and got a spurious trailing ".-" (e.g. "CICD Dashboard" ->
"CICD-Dashboard.-"), which then leaked into the stored slug, the on-disk
.md filename, and the API sub_url.

Fix: keep spaces intact through sanitizeWikiTitle (add space to the
allowed-character sets, drop the space->hyphen replacement, collapse
runs of spaces, and trim trailing spaces exposed by punctuation
trimming). The reversible space<->dash conversion and DashMarker logic
now happen only in escapeSegToWeb, as designed. Titles with a genuine
literal hyphen (e.g. "wiki-name" -> "wiki-name.-") still get the marker,
so the escape scheme stays reversible and existing escaped names still
decode.

Added regression cases to TestUserTitleToWebPath for the reported
titles (CICD Dashboard, Incident Response, Rollback Procedures, Backup
Recovery, 15 admin panels) plus a multi-space case. Removed a stale
"a%b" case that asserted pre-existing (unrelated) %-stripping behavior.

Claude-Session: https://claude.ai/code/session_01D5Zxu4xRRGoh9etzgShP4P
jmiller merged commit 8e1177f0af into dev 2026-07-19 07:04:43 +00:00
jmiller deleted branch fix/832-wiki-slug-trailing-dash-dot 2026-07-19 07:04:51 +00:00
Sign in to join this conversation.