Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>
it('should encode', () => {
// given
const path = 'test#test/test';
- const expectedResult = 'test%23test%2Ftest';
+ const expectedResult = 'test%23test/test';
// when
const result = customEncodeURI(path);
}
export const customEncodeURI = (path: string) => {
- return encodeURIComponent(path.replace(/%2F/g, '/'));
+ try {
+ return encodeURIComponent(path).replace(/%2F/g, '/');
+ } catch(e) {}
+
+ return path;
};
export const customDecodeURI = (path: string) => {
- return decodeURIComponent(path.replace(/\//g, '%2F'));
+ try {
+ return decodeURIComponent(path.replace(/\//g, '%2F'));
+ } catch(e) {}
+
+ return path;
};
export const encodeHash = (path: string) => {
? this.defaults.baseURL+'/'
: ''}${customEncodeURI(config.url)}`);
- if (config.headers && config.headers.Destination && config.headers.Destination.indexOf('#') > -1) {
+ if (config.headers && config.headers.Destination) {
config.headers.Destination = encodeHash(config.headers.Destination);
}
export const getTagValue = (document: Document | Element, tagName: string, defaultValue: string) => {
const [el] = Array.from(document.getElementsByTagName(tagName));
- return decodeURI(el ? htmlDecode(el.innerHTML) : defaultValue);
+ const URI = el ? htmlDecode(el.innerHTML) : defaultValue;
+
+ try {
+ return decodeURI(URI);
+ } catch(e) {}
+
+ return URI;
};
const htmlDecode = (input: string) => {
class Component<T> extends React.Component<TreeProps<T> & WithStyles<CssRules>, {}> {
render(): ReactElement<any> {
const { items, render } = this.props;
-
return <AutoSizer>
{({ height, width }) => {
return VirtualList(height, width, items || [], render, this.props);
const collectionUuid = collectionUuidMatch ? collectionUuidMatch.pop() : '';
const directory = url
.replace(collectionUrlPrefix, '')
- .replace(nameSuffix, '');
+ .replace(nameSuffix, '')
+ .replace(/\/\//g, '/');
const parentPath = directory.replace(/\/$/, '');
const data = {
path: parentPath,
};
- return getTagValue(element, 'D:resourcetype', '')
+ const result = getTagValue(element, 'D:resourcetype', '')
? createCollectionDirectory(data)
: createCollectionFile({ ...data, size });
+
+ return result;
});
};