aboutsummaryrefslogtreecommitdiff
path: root/modules/util/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/util/path.go')
-rw-r--r--modules/util/path.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/util/path.go b/modules/util/path.go
index 74acb7a85..5aa9e15f5 100644
--- a/modules/util/path.go
+++ b/modules/util/path.go
@@ -14,6 +14,14 @@ import (
"strings"
)
+// CleanPath ensure to clean the path
+func CleanPath(p string) string {
+ if strings.HasPrefix(p, "/") {
+ return path.Clean(p)
+ }
+ return path.Clean("/" + p)[1:]
+}
+
// EnsureAbsolutePath ensure that a path is absolute, making it
// relative to absoluteBase if necessary
func EnsureAbsolutePath(path, absoluteBase string) string {