Skip to content

Commit

Permalink
Should also support upper-case README files (#20581)
Browse files Browse the repository at this point in the history
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
  • Loading branch information
BLumia and lunny authored Aug 1, 2022
1 parent e56005f commit 72b1fd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/markup/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions modules/markup/renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 72b1fd7

Please sign in to comment.