From c86a2c9a189bd92828e7fa42dcb0c11ec71366f9 Mon Sep 17 00:00:00 2001 From: alessio Date: Mon, 22 Aug 2016 00:56:19 +0200 Subject: [PATCH] slash method fixed --- realize/watcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/realize/watcher.go b/realize/watcher.go index 0d474b1..f633afa 100644 --- a/realize/watcher.go +++ b/realize/watcher.go @@ -226,7 +226,7 @@ func inArray(str string, list []string) bool { // add a slash at the beginning if not exist func slash(str string) string { - if string(str[0]) != "/" { + if len(str) == 0 || string(str[0]) != "/" { str = "/" + str } if string(str[len(str)-1]) == "/" { @@ -235,7 +235,7 @@ func slash(str string) string { } else if string(str) == "/" { str = "" } else { - str = str[0 : len(str)-2] + str = str[0 : len(str)-1] } } return str