diff --git a/modules/markup/html.go b/modules/markup/html.go index 53f57af1e..4f9d02a8f 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -464,7 +464,11 @@ func shortLinkProcessorFull(ctx *postProcessCtx, node *html.Node, noLink bool) { childNode.Parent = linkNode absoluteLink := isLinkStr(link) if !absoluteLink { - link = strings.Replace(link, " ", "+", -1) + if image { + link = strings.Replace(link, " ", "+", -1) + } else { + link = strings.Replace(link, " ", "-", -1) + } } urlPrefix := ctx.urlPrefix if image { diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 203db243d..fc11532d1 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -81,11 +81,13 @@ func TestRender_ShortLinks(t *testing.T) { rawtree := util.URLJoin(AppSubURL, "raw", "master") url := util.URLJoin(tree, "Link") - otherURL := util.URLJoin(tree, "OtherLink") + otherURL := util.URLJoin(tree, "Other-Link") imgurl := util.URLJoin(rawtree, "Link.jpg") + otherImgurl := util.URLJoin(rawtree, "Link+Other.jpg") urlWiki := util.URLJoin(AppSubURL, "wiki", "Link") - otherURLWiki := util.URLJoin(AppSubURL, "wiki", "OtherLink") + otherURLWiki := util.URLJoin(AppSubURL, "wiki", "Other-Link") imgurlWiki := util.URLJoin(AppSubURL, "wiki", "raw", "Link.jpg") + otherImgurlWiki := util.URLJoin(AppSubURL, "wiki", "raw", "Link+Other.jpg") favicon := "http://google.com/favicon.ico" test( @@ -125,7 +127,11 @@ func TestRender_ShortLinks(t *testing.T) { `

AltName

`, `

AltName

`) test( - "[[Link]] [[OtherLink]]", - `

Link OtherLink

`, - `

Link OtherLink

`) + "[[Name|Link Other.jpg|alt=\"AltName\"|title='Title']]", + `

AltName

`, + `

AltName

`) + test( + "[[Link]] [[Other Link]]", + `

Link Other Link

`, + `

Link Other Link

`) }