/** * Copyright (c) 2023 MERCENARIES.AI PTE. LTD. * All rights reserved. */ function escapeHtmlSpecialChars(text: string) { if (!text || text.length === 0) { console.warn('null text passed into escapeHtmlSpecialChars'); return ''; } const map: Record = { '<': '<', '>': '>', '&': '&', '"': '"', "'": ''' }; return text.replace(/[<>&"']/g, (m) => map[m]); } export { escapeHtmlSpecialChars };