From 72b1fd7fdde76815ce3b2e6d19978fa7ade30a66 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Mon, 1 Aug 2022 20:15:40 +0800 Subject: [PATCH] Should also support upper-case README files (#20581) Co-authored-by: Lunny Xiao --- modules/markup/renderer.go | 2 ++ modules/markup/renderer_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/modules/markup/renderer.go b/modules/markup/renderer.go index 9278d4c65d..5f69dc7235 100644 --- a/modules/markup/renderer.go +++ b/modules/markup/renderer.go @@ -328,11 +328,13 @@ func IsReadmeFile(name string) bool { // the length of the provided extension list. // Note that the '.' should be provided in ext, e.g ".md" func IsReadmeFileExtension(name string, ext ...string) (int, bool) { + name = strings.ToLower(name) if len(name) < 6 || name[:6] != "readme" { return 0, false } for i, extension := range ext { + extension = strings.ToLower(extension) if name[6:] == extension { return i, true } diff --git a/modules/markup/renderer_test.go b/modules/markup/renderer_test.go index 1e0f7db194..950ee15b91 100644 --- a/modules/markup/renderer_test.go +++ b/modules/markup/renderer_test.go @@ -58,6 +58,16 @@ func TestMisc_IsReadmeFile(t *testing.T) { expected: true, idx: 0, }, + { + name: "README.md", + expected: true, + idx: 0, + }, + { + name: "ReAdMe.Md", + expected: true, + idx: 0, + }, { name: "readme.txt", expected: true,