aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Wang <wzc782970009@gmail.com>2022-08-01 20:15:40 +0800
committerGitHub <noreply@github.com>2022-08-01 20:15:40 +0800
commit72b1fd7fdde76815ce3b2e6d19978fa7ade30a66 (patch)
tree70b9ad34bf28cb2563cf0d9b203b261e21acefaa
parente56005f901141f7dcd5e82fc0755e6637f0784d8 (diff)
downloadgitea-72b1fd7fdde76815ce3b2e6d19978fa7ade30a66.tar.gz
gitea-72b1fd7fdde76815ce3b2e6d19978fa7ade30a66.zip
Should also support upper-case README files (#20581)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r--modules/markup/renderer.go2
-rw-r--r--modules/markup/renderer_test.go10
2 files changed, 12 insertions, 0 deletions
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
@@ -59,6 +59,16 @@ func TestMisc_IsReadmeFile(t *testing.T) {
idx: 0,
},
{
+ name: "README.md",
+ expected: true,
+ idx: 0,
+ },
+ {
+ name: "ReAdMe.Md",
+ expected: true,
+ idx: 0,
+ },
+ {
name: "readme.txt",
expected: true,
idx: 1,