2024-07-27 15:42:50 +08:00
|
|
|
|
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
|
2024-04-13 20:39:21 +08:00
|
|
|
|
|
|
|
|
|
|
package utils
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"strings"
|
2024-07-27 15:42:50 +08:00
|
|
|
|
|
|
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/utils/zero"
|
2024-04-13 20:39:21 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var commonFileExtensionsMap = map[string]zero.Zero{
|
|
|
|
|
|
".ico": zero.New(),
|
|
|
|
|
|
".jpg": zero.New(),
|
|
|
|
|
|
".jpeg": zero.New(),
|
|
|
|
|
|
".gif": zero.New(),
|
|
|
|
|
|
".png": zero.New(),
|
|
|
|
|
|
".webp": zero.New(),
|
|
|
|
|
|
".woff2": zero.New(),
|
|
|
|
|
|
".js": zero.New(),
|
|
|
|
|
|
".css": zero.New(),
|
|
|
|
|
|
".ttf": zero.New(),
|
|
|
|
|
|
".otf": zero.New(),
|
|
|
|
|
|
".fnt": zero.New(),
|
|
|
|
|
|
".svg": zero.New(),
|
|
|
|
|
|
".map": zero.New(),
|
2024-04-17 14:06:30 +08:00
|
|
|
|
".avif": zero.New(),
|
|
|
|
|
|
".bmp": zero.New(),
|
|
|
|
|
|
".cur": zero.New(),
|
2024-04-13 20:39:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IsCommonFileExtension 判断是否为常用文件扩展名
|
|
|
|
|
|
// 不区分大小写,且不限于是否加点符号(.)
|
|
|
|
|
|
func IsCommonFileExtension(ext string) bool {
|
|
|
|
|
|
if len(ext) == 0 {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
if ext[0] != '.' {
|
|
|
|
|
|
ext = "." + ext
|
|
|
|
|
|
}
|
|
|
|
|
|
_, ok := commonFileExtensionsMap[strings.ToLower(ext)]
|
|
|
|
|
|
return ok
|
|
|
|
|
|
}
|