File tree Expand file tree Collapse file tree 1 file changed +21
-11
lines changed
Expand file tree Collapse file tree 1 file changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,20 @@ import (
1212 "time"
1313)
1414
15- const AWESOMEREPOURL = "https://github.com/sindresorhus/awesome/ "
15+ const AWESOMEREPOURL = "https://github.com/sindresorhus/awesome"
1616const AWESOMECACHEFOLDER = ".awesomecache"
1717const RAWGITHUBUSERCONTENT = "https://raw.githubusercontent.com"
1818
19+ var BRANCHES = []string {"/master/" , "/main/" }
20+ var README_PATTERNS = []string {
21+ "README" ,
22+ "README.MD" ,
23+ "README.md" ,
24+ "readme" ,
25+ "readme.md" ,
26+ "readme.MD" ,
27+ }
28+
1929func FetchAwsomeRootRepo () (string , error ) {
2030 return FetchAwsomeRepo (AWESOMEREPOURL )
2131}
@@ -53,9 +63,8 @@ func FetchAwsomeRepo(repourl string) (string, error) {
5363 continue
5464 }
5565
56- defer response .Body .Close ()
57-
5866 responseData , err := ioutil .ReadAll (response .Body )
67+ response .Body .Close ()
5968
6069 if err != nil {
6170 log .Println (err )
@@ -81,16 +90,17 @@ func GetPossibleReadmeFileURLs(repourl string) []string {
8190 return []string {}
8291 }
8392
84- prefix := RAWGITHUBUSERCONTENT + u .Path + "/master/"
93+ prefix := RAWGITHUBUSERCONTENT + u .Path
8594
86- return []string {
87- prefix + "README" ,
88- prefix + "README.MD" ,
89- prefix + "README.md" ,
90- prefix + "readme" ,
91- prefix + "readme.md" ,
92- prefix + "readme.MD" ,
95+ var ret []string
96+
97+ for _ , br := range BRANCHES {
98+ for _ , readme := range README_PATTERNS {
99+ ret = append (ret , prefix + br + readme )
100+ }
93101 }
102+
103+ return ret
94104}
95105
96106func GetCachePath (url string ) string {
You can’t perform that action at this time.
0 commit comments