@@ -340,26 +340,37 @@ func WikiMedia(ctx *context.Context) {
340
340
return
341
341
}
342
342
}
343
+
343
344
providedPath := ctx .Params ("*" )
344
- if strings .HasSuffix (providedPath , ".md" ) {
345
- providedPath = providedPath [:len (providedPath )- 3 ]
346
- }
347
- wikiPath := models .WikiNameToFilename (providedPath )
345
+
348
346
var entry * git.TreeEntry
349
347
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
+ }
358
366
}
359
367
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
+ }
362
372
}
373
+ ctx .NotFound ("findEntryForFile" , nil )
363
374
}
364
375
365
376
// NewWiki render wiki create page
0 commit comments