feat: init sproutclaw-web — Go+Gin backend + React frontend

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 20:16:09 +08:00
commit c33b143176
109 changed files with 18773 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
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)
}