refactor(thumb): thumb logic for slave policy

This commit is contained in:
Aaron Liu
2023-04-07 19:25:29 +08:00
parent ae118c337e
commit 7cb5e68b78
15 changed files with 75 additions and 78 deletions

View File

@@ -2,6 +2,7 @@ package util
import (
"math/rand"
"path/filepath"
"regexp"
"strings"
"time"
@@ -32,6 +33,21 @@ func ContainsUint(s []uint, e uint) bool {
return false
}
// IsInExtensionList 返回文件的扩展名是否在给定的列表范围内
func IsInExtensionList(extList []string, fileName string) bool {
ext := strings.ToLower(filepath.Ext(fileName))
// 无扩展名时
if len(ext) == 0 {
return false
}
if ContainsString(extList, ext[1:]) {
return true
}
return false
}
// ContainsString 返回list中是否包含
func ContainsString(s []string, e string) bool {
for _, a := range s {