@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
52 lines • 1.54 kB
JavaScript
/*
* Copyright (c) 2025, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeHtmlEntities = void 0;
/**
* Clean a string by replacing HTML entities with their respective characters.
*
* @param str - The string to clean.
* @returns The cleaned string with all HTML entities replaced with their respective characters.
*/
const decodeHtmlEntities = (str = '') => {
const entities = {
'"': '"',
''': "'",
'&': '&',
'<': '<',
'>': '>',
''': "'",
'°': '°',
' ': ' ',
'–': '–',
'—': '—',
'’': '’',
'‘': '‘',
'“': '“',
'”': '”',
'…': '…',
'™': '™',
'©': '©',
'®': '®',
'€': '€',
'£': '£',
'¥': '¥',
'¢': '¢',
'×': '×',
'÷': '÷',
'±': '±',
'µ': 'µ',
'¶': '¶',
'§': '§',
'•': '•',
'·': '·',
};
return str.replace(/&[a-zA-Z0-9#]+;/g, (entity) => entities[entity] || entity);
};
exports.decodeHtmlEntities = decodeHtmlEntities;
//# sourceMappingURL=utils.js.map
;