From 31c58d34f19bc8a8d095c1ddec77dd75db62f7b9 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Tue, 14 Jul 2026 21:06:52 -0500 Subject: [PATCH] fix(org-wiki): also rewrite absolute-form intra-wiki links Match an optional https://host prefix so wiki links rendered as absolute URLs (not just root-relative) are rewritten to the /-/wiki/ route too. Covers nested pages like standards/Wiki-Structure. Claude-Session: https://claude.ai/code/session_01Bqe7fAuHQeiLueYfeHFrHw --- routers/web/org/wiki.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/web/org/wiki.go b/routers/web/org/wiki.go index 53f5d41188..510257d871 100644 --- a/routers/web/org/wiki.go +++ b/routers/web/org/wiki.go @@ -156,7 +156,7 @@ func Wiki(ctx *context.Context) { // wiki viewer instead of the repo file browser. func rewriteOrgWikiLinks(html htmltemplate.HTML, wikiRepo *repo_model.Repository, wikiBase string) htmltemplate.HTML { prefix := wikiRepo.Link() + "/src/branch/" + util.PathEscapeSegments(wikiRepo.DefaultBranch) + "/" - re := regexp.MustCompile(`href="` + regexp.QuoteMeta(prefix) + `([^"#?]*)([^"]*)"`) + re := regexp.MustCompile(`href="(?:https?://[^/"]+)?` + regexp.QuoteMeta(prefix) + `([^"#?]*)([^"]*)"`) out := re.ReplaceAllStringFunc(string(html), func(m string) string { sm := re.FindStringSubmatch(m) return `href="` + wikiBase + strings.TrimSuffix(sm[1], ".md") + sm[2] + `"`