From 08506f7e14c79a805f9ad5304aac278e2df8eb72 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Sat, 27 Feb 2021 22:23:19 +0100 Subject: [PATCH] Add html unescape function --- source/app/metrics/utils.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/app/metrics/utils.mjs b/source/app/metrics/utils.mjs index 44371ee0..cec8b551 100644 --- a/source/app/metrics/utils.mjs +++ b/source/app/metrics/utils.mjs @@ -86,6 +86,16 @@ .replace(/'/g, u["'"] ? "'" : "'") } +/**Unescape html */ + export function htmlunescape(string, u = {"&":true, "<":true, ">":true, '"':true, "'":true}) { + return string + .replace(/</g, u["<"] ? "<" : "<") + .replace(/>/g, u[">"] ? ">" : ">") + .replace(/"/g, u['"'] ? '"' : '"') + .replace(/'/g, u["'"] ? "'" : "'") + .replace(/&/g, u["&"] ? "&" : "&") + } + /**Run command */ export async function run(command, options, {prefixed = true} = {}) { const prefix = {win32:"wsl"}[process.platform] ?? ""