fix: 解决防盗链保存两次导致访问网站自动下载文件的问题 (#1489)

Refs https://github.com/1Panel-dev/1Panel/issues/1460
This commit is contained in:
zhengkunwang223 2023-06-29 18:42:11 +08:00 committed by GitHub
parent 38bf54ec3b
commit 2ff7726442
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -127,13 +127,27 @@ func (s *Server) RemoveDirective(key string, params []string) {
var newDirectives []IDirective
for _, dir := range directives {
if dir.GetName() == key {
if len(params) > 0 {
oldParams := dir.GetParameters()
if len(params) == 0 {
continue
}
oldParams := dir.GetParameters()
if key == "location" {
if len(params) == len(oldParams) {
exist := true
for i := range params {
if params[i] != oldParams[i] {
exist = false
break
}
}
if exist {
continue
}
}
} else {
if oldParams[0] == params[0] {
continue
}
} else {
continue
}
}
newDirectives = append(newDirectives, dir)