Should also support upper-case README files (#20581)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
tokarchuk/v1.18
Gary Wang 2 years ago committed by GitHub
parent e56005f901
commit 72b1fd7fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/markup/renderer.go
  2. 10
      modules/markup/renderer_test.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
}

@ -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,

Loading…
Cancel
Save