This commit is contained in:
Anya Tokugawa committed 2026-05-19 21:30:42 +09:00
commit fa6a4c650f
93 files changed
+6555

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
package server
import (
"strings"
)
func cleanSemanticPath(
path string,
) string {
if path == "" {
return "/"
}
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
if len(path) > 1 &&
strings.HasSuffix(path, "/") {
path = strings.TrimSuffix(
path,
"/",
)
}
return path
}
func parentPath(
path string,
) string {
path = cleanSemanticPath(path)
if path == "/" {
return "/"
}
idx := strings.LastIndex(path, "/")
if idx <= 0 {
return "/"
}
return path[:idx]
}