Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect replacement in markdown image links #26562

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func visitNode(ctx *RenderContext, procs, textProcs []processor, node *html.Node
if ctx.IsWiki {
prefix = util.URLJoin(prefix, "wiki", "raw")
}
prefix = strings.Replace(prefix, "/src/", "/media/", 1)
prefix = strings.Replace(prefix, "/src/branch/", "/media/branch/", 1)

attr.Val = util.URLJoin(prefix, attr.Val)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/markup/markdown/goldmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
if pc.Get(isWikiKey).(bool) {
prefix = giteautil.URLJoin(prefix, "wiki", "raw")
}
prefix = strings.Replace(prefix, "/src/", "/media/", 1)
prefix = strings.Replace(prefix, "/src/branch/", "/media/branch/", 1)

lnk := strings.TrimLeft(string(link), "/")

Expand Down
2 changes: 1 addition & 1 deletion modules/markup/orgmode/orgmode.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func getMediaURL(l []byte) string {

// Check if link is valid
if len(srcURL) > 0 && !markup.IsLink(l) {
srcURL = strings.Replace(srcURL, "/src/", "/media/", 1)
srcURL = strings.Replace(srcURL, "/src/branch/", "/media/branch/", 1)
}

return srcURL
Expand Down