Name hardcoded values
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 13 Aug 2018 12:03:57 +0000 (14:03 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 13 Aug 2018 12:03:57 +0000 (14:03 +0200)
Feature #13990

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/services/collection-service/collection-service.ts

index 4bb93a4a62b3fd888b6317b7d20c0afef049052b..8cf515c97853060b94c894b4764c72e466488f95 100644 (file)
@@ -47,6 +47,7 @@ export class CollectionService extends CommonResourceService<CollectionResource>
     }
 
     extractFilesData(document: Document) {
+        const collectionUrlPrefix = /\/c=[0-9a-zA-Z\-]*/;
         return Array
             .from(document.getElementsByTagName('D:response'))
             .slice(1) // omit first element which is collection itself
@@ -54,7 +55,10 @@ export class CollectionService extends CommonResourceService<CollectionResource>
                 const name = getTagValue(element, 'D:displayname', '');
                 const size = parseInt(getTagValue(element, 'D:getcontentlength', '0'), 10);
                 const pathname = getTagValue(element, 'D:href', '');
-                const directory = pathname && pathname.replace(/\/c=[0-9a-zA-Z\-]*/, '').replace(`/${name || ''}`, '');
+                const nameSuffix = `/${name || ''}`;
+                const directory = pathname
+                    .replace(collectionUrlPrefix, '')
+                    .replace(nameSuffix, '');
                 const href = this.webdavClient.defaults.baseURL + pathname + '?api_token=' + this.authService.getApiToken();
 
                 const data = {