diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index f02c5c275ff34727d8fcdc73ab12b409f06eeefb..faa0646e2ac26cb3526f73d79c70c66d13256a4e 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -263,16 +263,15 @@ dav_upload_folder() {
     # with the server path prefix ('private-upload/docs/test/')
     # to make something like '../folder1/folder2/folder-to-upload/test.txt'
     # into 'private-upload/docs/test.txt'
-    local server_path="${fname/$1/$2}"
-    server_path=${server_path%?} #remove double slash by the end
+    local server_path="${fname/$1/}"
 
     # if its a file...
     if [[ -f "${fname}" ]]; then
       # upload the file ...
-      dav_upload "${fname}" "${server_path}"
+      dav_upload "${fname}" "${2}${server_path}"
     else
       # if its a dir, create the dir
-      dav_mkdir "${server_path}"
+      dav_mkdir "${2}${server_path}"
     fi
   done
 }