17337: Added more tests to cover edge cases
[arvados-workbench2.git] / src / common / xml.ts
index 751a327c77cb48ec64cc23611bb4834c5388e093..e7db3acad8d904b58b4ae0c2061023eaade227b4 100644 (file)
@@ -2,13 +2,17 @@
 //
 // 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));
     const URI = el ? htmlDecode(el.innerHTML) : defaultValue;
 
-    try {
-        return decodeURI(URI);
-    } catch(e) {}
+    if (!skipDecoding) {
+        try {
+            return customDecodeURI(URI);
+        } catch(e) {}
+    }
 
     return URI;
 };