/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

/**
 * Decodes common HTML entities in a string.
 *
 * @param {string} text - Text that may contain HTML entities
 * @returns {string} Text with HTML entities replaced with their corresponding characters
 */
module.exports = function decodeHtmlEntities( text ) {
	return text
		.replace( /&nbsp;/g, ' ' )
		.replace( /&amp;/g, '&' )
		.replace( /&lt;/g, '<' )
		.replace( /&gt;/g, '>' )
		.replace( /&quot;/g, '"' )
		.replace( /&apos;/g, '\'' )
		.replace( /&mdash;/g, '—' )
		.replace( /&ndash;/g, '–' )
		.replace( /&hellip;/g, '…' );
};
