X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f5f72a4ee9b00aab5492f8991677b6503a6f2ac3..671aae429289611510af1facbc59c96c318293a2:/src/services/collection-service/collection-service-files-response.ts diff --git a/src/services/collection-service/collection-service-files-response.ts b/src/services/collection-service/collection-service-files-response.ts index 9a05fb61..b7e1f9c7 100644 --- a/src/services/collection-service/collection-service-files-response.ts +++ b/src/services/collection-service/collection-service-files-response.ts @@ -3,9 +3,8 @@ // SPDX-License-Identifier: AGPL-3.0 import { CollectionDirectory, CollectionFile, CollectionFileType, createCollectionDirectory, createCollectionFile } from "../../models/collection-file"; -import { getTagValue } from "~/common/xml"; -import { getNodeChildren, Tree, mapTree } from '~/models/tree'; -import { customDecodeURI } from "~/common/url"; +import { getTagValue } from "common/xml"; +import { getNodeChildren, Tree, mapTree } from 'models/tree'; export const sortFilesTree = (tree: Tree) => { return mapTree(node => { @@ -21,20 +20,22 @@ export const sortFilesTree = (tree: Tree) }; export const extractFilesData = (document: Document) => { - const collectionUrlPrefix = /\/c=([^\/]*)/; + const collectionUrlPrefix = /\/c=([^/]*)/; return Array .from(document.getElementsByTagName('D:response')) .slice(1) // omit first element which is collection itself .map(element => { - const name = getTagValue(element, 'D:displayname', ''); - const size = parseInt(getTagValue(element, 'D:getcontentlength', '0'), 10); - const url = customDecodeURI(getTagValue(element, 'D:href', '')); - const nameSuffix = name; + const name = getTagValue(element, 'D:displayname', '', true); // skip decoding as value should be already decoded + const size = parseInt(getTagValue(element, 'D:getcontentlength', '0', true), 10); + const url = getTagValue(element, 'D:href', '', true); const collectionUuidMatch = collectionUrlPrefix.exec(url); const collectionUuid = collectionUuidMatch ? collectionUuidMatch.pop() : ''; - const directory = url + const pathArray = url.split(`/`); + if (!pathArray.pop()) { + pathArray.pop(); + } + const directory = pathArray.join('/') .replace(collectionUrlPrefix, '') - .replace(nameSuffix, '') .replace(/\/\//g, '/'); const parentPath = directory.replace(/\/$/, ''); @@ -42,11 +43,11 @@ export const extractFilesData = (document: Document) => { url, id: [ collectionUuid ? collectionUuid : '', - directory ? parentPath : '', + directory ? unescape(parentPath) : '', '/' + name ].join(''), name, - path: parentPath, + path: unescape(parentPath), }; const result = getTagValue(element, 'D:resourcetype', '')