chore: Something update from clash :) (#606)

This commit is contained in:
タイムライン
2023-06-06 09:45:05 +08:00
committed by GitHub
parent e7174866e5
commit dafecebdc0
11 changed files with 100 additions and 31 deletions

View File

@ -56,6 +56,18 @@ func (p *path) Resolve(path string) string {
return path
}
// IsSubPath return true if path is a subpath of homedir
func (p *path) IsSubPath(path string) bool {
homedir := p.HomeDir()
path = p.Resolve(path)
rel, err := filepath.Rel(homedir, path)
if err != nil {
return false
}
return !strings.Contains(rel, "..")
}
func (p *path) MMDB() string {
files, err := os.ReadDir(p.homeDir)
if err != nil {