diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index faa0646e2ac26cb3526f73d79c70c66d13256a4e..06f0691c46538e9c409a1fc75c1ab8cd1d33649e 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -263,15 +263,16 @@ 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/}"
+    local server_prefix="${2%?}" #without ending slash
+    local server_path="${fname/$1/$2}"
 
     # if its a file...
     if [[ -f "${fname}" ]]; then
       # upload the file ...
-      dav_upload "${fname}" "${2}${server_path}"
+      dav_upload "${fname}" "${server_path}"
     else
       # if its a dir, create the dir
-      dav_mkdir "${2}${server_path}"
+      dav_mkdir "${server_path}"
     fi
   done
 }