Skip to content

Fix issue with broken inter-wiki links #3506 #3560

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

Merged
merged 1 commit into from
Mar 5, 2018
Merged
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
6 changes: 5 additions & 1 deletion modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 11 additions & 5 deletions modules/markup/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
urlUncyclo := util.URLJoin(AppSubURL, "wiki", "Link")
otherURLUncyclo := util.URLJoin(AppSubURL, "wiki", "OtherLink")
otherURLUncyclo := util.URLJoin(AppSubURL, "wiki", "Other-Link")
imgurlUncyclo := util.URLJoin(AppSubURL, "wiki", "raw", "Link.jpg")
otherImgurlUncyclo := util.URLJoin(AppSubURL, "wiki", "raw", "Link+Other.jpg")
favicon := "http://google.com/favicon.ico"

test(
Expand Down Expand Up @@ -125,7 +127,11 @@ func TestRender_ShortLinks(t *testing.T) {
`<p><a href="`+imgurl+`" rel="nofollow"><img src="`+imgurl+`" title="Title" alt="AltName"/></a></p>`,
`<p><a href="`+imgurlUncyclo+`" rel="nofollow"><img src="`+imgurlUncyclo+`" title="Title" alt="AltName"/></a></p>`)
test(
"[[Link]] [[OtherLink]]",
`<p><a href="`+url+`" rel="nofollow">Link</a> <a href="`+otherURL+`" rel="nofollow">OtherLink</a></p>`,
`<p><a href="`+urlUncyclo+`" rel="nofollow">Link</a> <a href="`+otherURLUncyclo+`" rel="nofollow">OtherLink</a></p>`)
"[[Name|Link Other.jpg|alt=\"AltName\"|title='Title']]",
`<p><a href="`+otherImgurl+`" rel="nofollow"><img src="`+otherImgurl+`" title="Title" alt="AltName"/></a></p>`,
`<p><a href="`+otherImgurlUncyclo+`" rel="nofollow"><img src="`+otherImgurlUncyclo+`" title="Title" alt="AltName"/></a></p>`)
test(
"[[Link]] [[Other Link]]",
`<p><a href="`+url+`" rel="nofollow">Link</a> <a href="`+otherURL+`" rel="nofollow">Other Link</a></p>`,
`<p><a href="`+urlUncyclo+`" rel="nofollow">Link</a> <a href="`+otherURLUncyclo+`" rel="nofollow">Other Link</a></p>`)
}