diff --git a/Specialized Areas/Flow Actions/Remove HTML Tags from a String in a Flow/removeHtmlTags.js b/Specialized Areas/Flow Actions/Remove HTML Tags from a String in a Flow/removeHtmlTags.js index f5608cdb09..47f79b9120 100644 --- a/Specialized Areas/Flow Actions/Remove HTML Tags from a String in a Flow/removeHtmlTags.js +++ b/Specialized Areas/Flow Actions/Remove HTML Tags from a String in a Flow/removeHtmlTags.js @@ -1,4 +1,21 @@ -(function execute(inputs, outputs) { - var htmlString = inputs.htmlValue || ''; - outputs.plainString = htmlString.replace(/<[^>]+>/g, '').trim(); -})(inputs, outputs); +function removeHtmlTags(value) { + if (value === null || value === undefined) { + return ''; + } + + var stringValue = String(value); + var withoutTags = stringValue.replace(/<[^>]+>/g, ' '); + + return withoutTags.replace(/\s+/g, ' ').trim(); +} + +if (typeof module !== 'undefined') { + module.exports = removeHtmlTags; +} + +if (typeof inputs !== 'undefined' && typeof outputs !== 'undefined') { + (function execute(inputs, outputs) { + var htmlString = inputs.htmlValue || ''; + outputs.plainString = removeHtmlTags(htmlString); + })(inputs, outputs); +}