1
0
Fork 0
forked from forgejo/forgejo

Prioritize "readme.md" (#5691)

* prioritize readme.md

* Improve IsReadmeFile

* Add more tests
This commit is contained in:
Khaled Hamed 2019-01-14 21:15:06 +02:00 committed by techknowlogick
parent 6868378673
commit bd75965296
3 changed files with 47 additions and 7 deletions

View file

@ -111,9 +111,14 @@ func IsMarkupFile(name, markup string) bool {
}
// IsReadmeFile reports whether name looks like a README file
// based on its name.
func IsReadmeFile(name string) bool {
// based on its name. If an extension is provided, it will strictly
// match that extension.
// Note that the '.' should be provided in ext, e.g ".md"
func IsReadmeFile(name string, ext ...string) bool {
name = strings.ToLower(name)
if len(ext) > 0 {
return name == "readme"+ext[0]
}
if len(name) < 6 {
return false
} else if len(name) == 6 {