15027: Cleans up unused imports.
[arvados-workbench2.git] / src / services / collection-service / collection-service-files-response.ts
index b8a7970d58d4310d8228b8d0c80fb04188614810..619a4fc78582270558aa51ac07986ba578ed1c02 100644 (file)
@@ -26,7 +26,7 @@ export const sortFilesTree = (tree: Tree<CollectionDirectory | CollectionFile>)
 };
 
 export const extractFilesData = (document: Document) => {
-    const collectionUrlPrefix = /\/c=[0-9a-zA-Z\-]*/;
+    const collectionUrlPrefix = /\/c=([^\/]*)/;
     return Array
         .from(document.getElementsByTagName('D:response'))
         .slice(1) // omit first element which is collection itself
@@ -35,13 +35,20 @@ export const extractFilesData = (document: Document) => {
             const size = parseInt(getTagValue(element, 'D:getcontentlength', '0'), 10);
             const url = getTagValue(element, 'D:href', '');
             const nameSuffix = `/${name || ''}`;
+            const collectionUuidMatch = collectionUrlPrefix.exec(url);
+            const collectionUuid = collectionUuidMatch ? collectionUuidMatch.pop() : '';
             const directory = url
                 .replace(collectionUrlPrefix, '')
                 .replace(nameSuffix, '');
 
+
             const data = {
                 url,
-                id: `${directory}/${name}`,
+                id: [
+                    collectionUuid ? collectionUuid : '',
+                    directory ? '/' + directory.replace(/^\//, '') : '',
+                    '/' + name
+                ].join(''),
                 name,
                 path: directory,
             };
@@ -52,3 +59,6 @@ export const extractFilesData = (document: Document) => {
 
         });
 };
+
+export const getFileFullPath = ({ name, path }: CollectionFile | CollectionDirectory) =>
+    `${path}/${name}`;