Ghost/ghost/admin/app/helpers/gh-count-down-html-characters.js
Simon Backx c3c2427992 Fixed gh-count-down-html-characters helper to support null values
no issue

The default null value for the sigup terms caused an error. This fixes that issue.
2023-04-11 17:49:37 +02:00

22 lines
719 B
JavaScript

import {countDownCharacters} from './gh-count-down-characters';
import {helper} from '@ember/component/helper';
export default helper(function (params) {
let [content, maxCharacters] = params;
if (!content) {
// Protect against NULL content
content = '';
}
// Strip HTML-tags and characters from content so we have a reliable character count
content = content.replace(/<[^>]*>?/gm, '');
content = content.replace(/&nbsp;/g, ' ');
content = content.replace(/&amp;/g, '&');
content = content.replace(/&quot;/g, '"');
content = content.replace(/&lt;/g, '<');
content = content.replace(/&gt;/g, '>');
return countDownCharacters([content, maxCharacters]);
});