修复 ignore 与 not found 结果不一致的问题
This commit is contained in:
@@ -59,7 +59,7 @@ func (m *PageMetaContent) From(data string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PageMetaContent) IsIgnore(path string) bool {
|
func (m *PageMetaContent) IgnorePath(path string) bool {
|
||||||
for _, g := range m.ignoreL {
|
for _, g := range m.ignoreL {
|
||||||
if g.Match(path) {
|
if g.Match(path) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -148,11 +148,13 @@ func (s *Server) Serve(writer http.ResponseWriter, request *http.Request) error
|
|||||||
if request.Method != "GET" {
|
if request.Method != "GET" {
|
||||||
return os.ErrNotExist
|
return os.ErrNotExist
|
||||||
}
|
}
|
||||||
if meta.IsIgnore(meta.Path) {
|
var result io.ReadCloser
|
||||||
|
if meta.IgnorePath(meta.Path) {
|
||||||
zap.L().Debug("ignore path", zap.Any("request", request.RequestURI), zap.Any("meta.path", meta.Path))
|
zap.L().Debug("ignore path", zap.Any("request", request.RequestURI), zap.Any("meta.path", meta.Path))
|
||||||
return os.ErrNotExist
|
err = os.ErrNotExist
|
||||||
|
} else {
|
||||||
|
result, err = s.reader.Open(meta.Owner, meta.Repo, meta.CommitID, meta.Path)
|
||||||
}
|
}
|
||||||
result, err := s.reader.Open(meta.Owner, meta.Repo, meta.CommitID, meta.Path)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
if meta.VRoute {
|
if meta.VRoute {
|
||||||
|
|||||||
Reference in New Issue
Block a user