diff --git a/modules/base/markdown.go b/modules/base/markdown.go index e49e111c0e1..2273cd772fd 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -36,7 +36,7 @@ func isLink(link []byte) bool { func IsMarkdownFile(name string) bool { name = strings.ToLower(name) switch filepath.Ext(name) { - case "md", "markdown", "mdown": + case ".md", ".markdown", ".mdown": return true } return false diff --git a/routers/repo/single.go b/routers/repo/single.go index 49eb55d3e04..e218bc9158d 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -96,7 +96,11 @@ func Single(ctx *middleware.Context, params martini.Params) { } else { ctx.Data["IsFile"] = true ctx.Data["FileName"] = repoFile.Name - ctx.Data["FileExt"] = path.Ext(repoFile.Name) + ext := path.Ext(repoFile.Name) + if len(ext) > 0 { + ext = ext[1:] + } + ctx.Data["FileExt"] = ext readmeExist := base.IsMarkdownFile(repoFile.Name) || base.IsReadmeFile(repoFile.Name) ctx.Data["ReadmeExist"] = readmeExist