Lint project

This commit is contained in:
JY Tan
2025-12-18 17:02:09 -08:00
parent 55230dd774
commit 14a737a36b
9 changed files with 66 additions and 47 deletions

View File

@@ -26,14 +26,15 @@ func NormalizePath(pathPattern string) string {
normalized := pathPattern
// Expand ~ to home directory
if pathPattern == "~" {
// Expand ~ and relative paths
switch {
case pathPattern == "~":
normalized = home
} else if strings.HasPrefix(pathPattern, "~/") {
case strings.HasPrefix(pathPattern, "~/"):
normalized = filepath.Join(home, pathPattern[2:])
} else if strings.HasPrefix(pathPattern, "./") || strings.HasPrefix(pathPattern, "../") {
case strings.HasPrefix(pathPattern, "./"), strings.HasPrefix(pathPattern, "../"):
normalized, _ = filepath.Abs(filepath.Join(cwd, pathPattern))
} else if !filepath.IsAbs(pathPattern) && !ContainsGlobChars(pathPattern) {
case !filepath.IsAbs(pathPattern) && !ContainsGlobChars(pathPattern):
normalized, _ = filepath.Abs(filepath.Join(cwd, pathPattern))
}