init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -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]
|
||||
}
|
||||
Reference in new issue
Block a user