Skip to content

fix: convert wiki page titles to sub_url slugs for get/edit/delete#6

Open
Lcstyle wants to merge 1 commit intoraohwork:masterfrom
Lcstyle:fix/wiki-page-slug-encoding
Open

fix: convert wiki page titles to sub_url slugs for get/edit/delete#6
Lcstyle wants to merge 1 commit intoraohwork:masterfrom
Lcstyle:fix/wiki-page-slug-encoding

Conversation

@Lcstyle
Copy link
Copy Markdown

@Lcstyle Lcstyle commented Mar 26, 2026

Summary

  • get_wiki_page, edit_wiki_page, and delete_wiki_page now accept display titles (e.g. architecture/overview) in addition to raw sub_url slugs
  • New wikiPageNameToSlug helper converts titles to Gitea's expected slug format: spaces → hyphens, /%2F, append .- suffix for nested pages
  • Already-encoded sub_url values pass through unchanged (no double-encoding)
  • 7 unit tests covering flat pages, nested pages, deep nesting, spaces, and passthrough

Problem

When an MCP client lists wiki pages via list_wiki_pages and sees a title like architecture/signal-processing-strategies, it naturally passes that title to get_wiki_page. But Gitea's API expects the sub_url slug format (architecture%2Fsignal-processing-strategies.-), resulting in a 404.

See #5 for full reproduction steps.

Test plan

  • All 7 new TestWikiPageNameToSlug tests pass
  • All 45 existing tests pass (0 regressions)
  • Manual verification against Gitea 1.25.4: nested pages, flat pages, deep nesting, already-encoded slugs all return 200

🤖 Generated with Claude Code

The Gitea API expects the sub_url slug format for wiki page endpoints,
not the display title. This caused 404 errors when callers passed page
titles (e.g. "architecture/overview") to get_wiki_page, edit_wiki_page,
or delete_wiki_page.

The new wikiPageNameToSlug helper converts titles to slugs:
- Replaces spaces with hyphens
- URL-encodes path separators (/ -> %2F)
- Appends ".-" suffix for pages with path separators (Gitea convention)
- Passes through already-encoded sub_url values unchanged

Includes 7 unit tests covering flat pages, nested pages, deep nesting,
spaces, and already-encoded passthrough.

Fixes raohwork#5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant