Skip to content

Commit 8b224e8

Browse files
committed
Adjust media path to match #5184
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 35dc5b9 commit 8b224e8

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

routers/repo/wiki.go

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,26 +340,37 @@ func WikiMedia(ctx *context.Context) {
340340
return
341341
}
342342
}
343+
343344
providedPath := ctx.Params("*")
344-
if strings.HasSuffix(providedPath, ".md") {
345-
providedPath = providedPath[:len(providedPath)-3]
346-
}
347-
wikiPath := models.WikiNameToFilename(providedPath)
345+
348346
var entry *git.TreeEntry
349347
if commit != nil {
350-
entry, err = findEntryForFile(commit, wikiPath)
351-
}
352-
if err != nil {
353-
ctx.ServerError("findFile", err)
354-
return
355-
} else if entry == nil {
356-
ctx.NotFound("findEntryForFile", nil)
357-
return
348+
entry, err = findEntryForFile(commit, providedPath)
349+
if err != nil {
350+
ctx.ServerError("findFile", err)
351+
}
352+
353+
if entry == nil {
354+
// Try to find a wiki page with that name
355+
if strings.HasSuffix(providedPath, ".md") {
356+
providedPath = providedPath[:len(providedPath)-3]
357+
}
358+
359+
wikiPath := models.WikiNameToFilename(providedPath)
360+
entry, err = findEntryForFile(commit, wikiPath)
361+
if err != nil {
362+
ctx.ServerError("findFile", err)
363+
return
364+
}
365+
}
358366
}
359367

360-
if err = ServeBlobOrLFS(ctx, entry.Blob()); err != nil {
361-
ctx.ServerError("ServeBlob", err)
368+
if entry != nil {
369+
if err = ServeBlobOrLFS(ctx, entry.Blob()); err != nil {
370+
ctx.ServerError("ServeBlob", err)
371+
}
362372
}
373+
ctx.NotFound("findEntryForFile", nil)
363374
}
364375

365376
// NewWiki render wiki create page

0 commit comments

Comments
 (0)