diff options
Diffstat (limited to 'apps/comments/src/utils/decodeHtmlEntities.js')
-rw-r--r-- | apps/comments/src/utils/decodeHtmlEntities.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/comments/src/utils/decodeHtmlEntities.js b/apps/comments/src/utils/decodeHtmlEntities.js new file mode 100644 index 00000000000..4c492954256 --- /dev/null +++ b/apps/comments/src/utils/decodeHtmlEntities.js @@ -0,0 +1,17 @@ +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +/** + * @param {any} value - + * @param {any} passes - + */ +export function decodeHtmlEntities(value, passes = 1) { + const parser = new DOMParser() + let decoded = value + for (let i = 0; i < passes; i++) { + decoded = parser.parseFromString(decoded, 'text/html').documentElement.textContent + } + return decoded +} |