Skip to content

Commit d4ebbfd

Browse files
committed
fix(handler): use regex to check whether a readme file
1 parent 4b89b17 commit d4ebbfd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/handles/down.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
stdpath "path"
8+
"regexp"
89
"strconv"
910
"strings"
1011

@@ -131,7 +132,8 @@ func localProxy(c *gin.Context, link *model.Link, file model.Obj, proxyRange boo
131132
Writer := &common.WrittenResponseWriter{ResponseWriter: c.Writer}
132133

133134
//优先处理md文件
134-
if file.GetName() == "README.md" && setting.GetBool(conf.FilterReadMeScripts) {
135+
readmeRe := regexp.MustCompile(`(?i)^readme\.md$`)
136+
if readmeRe.MatchString(file.GetName()) && setting.GetBool(conf.FilterReadMeScripts) {
135137
buf := bytes.NewBuffer(make([]byte, 0, file.GetSize()))
136138
w := &common.InterceptResponseWriter{ResponseWriter: Writer, Writer: buf}
137139
err = common.Proxy(w, c.Request, link, file)

0 commit comments

Comments
 (0)