package utils import ( "path/filepath" "strings" ) // IsPathInsideRoot returns true if candidate is inside (or equal to) root. // Both paths are cleaned and compared case-insensitively on Windows. func IsPathInsideRoot(root, candidate string) bool { root = filepath.Clean(root) candidate = filepath.Clean(candidate) // normalize separators root = filepath.ToSlash(root) candidate = filepath.ToSlash(candidate) // case-insensitive on Windows rootLow := strings.ToLower(root) candLow := strings.ToLower(candidate) return candLow == rootLow || strings.HasPrefix(candLow, rootLow+"/") } // IsSameResolvedPath compares two paths after cleaning. func IsSameResolvedPath(a, b string) bool { return filepath.Clean(a) == filepath.Clean(b) }