};
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
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,
};
});
};
+
+export const getFileFullPath = ({ name, path }: CollectionFile | CollectionDirectory) =>
+ `${path}/${name}`;