1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 export const getTagValue = (document: Document | Element, tagName: string, defaultValue: string) => {
6 const [el] = Array.from(document.getElementsByTagName(tagName));
7 return decodeURI(el ? htmlDecode(el.innerHTML) : defaultValue);
10 const htmlDecode = (input: string) => {
11 const out = input.split(' ').map((i) => {
12 const doc = new DOMParser().parseFromString(i, "text/html");
13 if (doc.documentElement !== null) {
14 return doc.documentElement.textContent || '';