Merge branch '17337-files-not-visible-in-arvados'
[arvados-workbench2.git] / src / common / xml.ts
index 3c6feb5dce8836a92a08074ba32a768af4ec84fc..e7db3acad8d904b58b4ae0c2061023eaade227b4 100644 (file)
@@ -2,9 +2,19 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-export const getTagValue = (document: Document | Element, tagName: string, defaultValue: string) => {
+import { customDecodeURI } from "./url";
+
+export const getTagValue = (document: Document | Element, tagName: string, defaultValue: string, skipDecoding: boolean = false) => {
     const [el] = Array.from(document.getElementsByTagName(tagName));
-    return decodeURI(el ? htmlDecode(el.innerHTML) : defaultValue);
+    const URI = el ? htmlDecode(el.innerHTML) : defaultValue;
+
+    if (!skipDecoding) {
+        try {
+            return customDecodeURI(URI);
+        } catch(e) {}
+    }
+
+    return URI;
 };
 
 const htmlDecode = (input: string) => {