1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { customDecodeURI } from "./url";
7 export const getTagValue = (document: Document | Element, tagName: string, defaultValue: string, skipDecoding: boolean = false) => {
8 const [el] = Array.from(document.getElementsByTagName(tagName));
9 const URI = el ? htmlDecode(el.innerHTML) : defaultValue;
13 return customDecodeURI(URI);
20 const htmlDecode = (input: string) => {
21 const out = input.split(' ').map((i) => {
22 const doc = new DOMParser().parseFromString(i, "text/html");
23 if (doc.documentElement !== null) {
24 return doc.documentElement.textContent || '';