18169: Removed cancel disable when uploading
[arvados-workbench2.git] / src / common / webdav.ts
index 0b77f8c33262e9b7b0b284b4da682d6ec58ceb85..93ec21cb724f26d2ede4cf9be4b211defaf85b9c 100644 (file)
@@ -79,17 +79,20 @@ export class WebDAV {
                     ? this.defaults.baseURL+'/'
                     : ''}${customEncodeURI(config.url)}`);
 
-            if (config.headers && config.headers.Destination) {
-                const regexp = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/;
-                const match = decodeURIComponent(config.headers.Destination).match(regexp) || {};
-                config.headers.Destination = `${match[1]}${match[2]}${customEncodeURI(match[3])}`;
-            }
-
             const headers = { ...this.defaults.headers, ...config.headers };
             Object
                 .keys(headers)
                 .forEach(key => r.setRequestHeader(key, headers[key]));
 
+            if (!(window as any).cancelTokens) {
+                Object.assign(window, { cancelTokens: {} });
+            }
+
+            (window as any).cancelTokens[config.url] = () => { 
+                resolve(r);
+                r.abort();
+            }
+
             if (config.onUploadProgress) {
                 r.upload.addEventListener('progress', config.onUploadProgress);
             }