17337: Added custom encode functions with tests
[arvados-workbench2.git] / src / common / webdav.ts
index 54601f16d2e5a380b315e8d8eb9834d2228bcb38..ca3b6d74686093ad75b3776faa29499ca9684de6 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { escapeHashIfRequired } from "./url";
+import { customEncodeURI, encodeHash } from "./url";
 
 export class WebDAV {
 
@@ -77,7 +77,12 @@ export class WebDAV {
             r.open(config.method,
                 `${this.defaults.baseURL
                     ? this.defaults.baseURL+'/'
-                    : ''}${escapeHashIfRequired(config.url, encodeURI)}`);
+                    : ''}${customEncodeURI(config.url)}`);
+
+            if (config.headers && config.headers.Destination && config.headers.Destination.indexOf('#') > -1) {
+                config.headers.Destination = encodeHash(config.headers.Destination);
+            }
+
             const headers = { ...this.defaults.headers, ...config.headers };
             Object
                 .keys(headers)