静态分发增加例外URL、限制URL、排除隐藏文件等选项

This commit is contained in:
GoEdgeLab
2023-08-10 11:27:24 +08:00
parent 107e8c3e2f
commit 588848b361

View File

@@ -66,6 +66,19 @@ func (this *HTTPRequest) doRoot() (isBreak bool) {
requestPath = this.uri[:questionMarkIndex]
}
// except hidden files
if this.web.Root.ExceptHiddenFiles &&
(strings.Contains(requestPath, "/.") || strings.Contains(requestPath, "\\.")) {
this.write404()
return true
}
// except and only files
if !this.web.Root.MatchURL(this.URL()) {
this.write404()
return true
}
// 去掉其中的奇怪的路径
requestPath = strings.Replace(requestPath, "..\\", "", -1)