fix(org-wiki): also rewrite absolute-form intra-wiki links
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 1m26s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 1m26s
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
This commit is contained in:
@@ -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] + `"`
|
||||
|
||||
Reference in New Issue
Block a user