summaryrefslogtreecommitdiff
path: root/internal/ctlsock/sanitize.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ctlsock/sanitize.go')
-rw-r--r--internal/ctlsock/sanitize.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/ctlsock/sanitize.go b/internal/ctlsock/sanitize.go
new file mode 100644
index 0000000..5bc3706
--- /dev/null
+++ b/internal/ctlsock/sanitize.go
@@ -0,0 +1,20 @@
+package ctlsock
+
+import (
+ "path/filepath"
+)
+
+// SanitizePath adapts filepath.Clean for FUSE paths.
+// 1) It always returns a relative path
+// 2) It returns "" instead of "."
+// See the TestSanitizePath testcases for examples.
+func SanitizePath(path string) string {
+ clean := filepath.Clean(path)
+ if clean == "." || clean == "/" {
+ return ""
+ }
+ if clean[0] == '/' {
+ clean = clean[1:]
+ }
+ return clean
+}