feat: some updates

This commit is contained in:
Max Richter
2025-09-24 18:18:57 +02:00
parent b3c01bb43d
commit 26c303d9cf
32 changed files with 464 additions and 263 deletions

View File

@@ -12,7 +12,7 @@ func CleanURLLike(p string) string {
return "/"
}
parts := []string{}
for _, seg := range strings.Split(strings.ReplaceAll(p, "\\", "/"), "/") {
for seg := range strings.SplitSeq(strings.ReplaceAll(p, "/", "/"), "/") {
switch seg {
case "", ".":
continue
@@ -29,8 +29,8 @@ func CleanURLLike(p string) string {
func SafeRel(root, requested string) (string, error) {
s := CleanURLLike(requested)
if strings.HasPrefix(s, "/") {
s = strings.TrimPrefix(s, "/")
if after, ok := strings.CutPrefix(s, "/"); ok {
s = after
}
full := filepath.Join(root, filepath.FromSlash(s))
rel, err := filepath.Rel(root, full)