mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
17 lines
630 B
JavaScript
17 lines
630 B
JavaScript
|
import {countDownCharacters} from './gh-count-down-characters';
|
||
|
import {helper} from '@ember/component/helper';
|
||
|
|
||
|
export default helper(function (params) {
|
||
|
let [content, maxCharacters] = params;
|
||
|
|
||
|
// Strip HTML-tags and characters from content so we have a reliable character count
|
||
|
content = content.replace(/<[^>]*>?/gm, '');
|
||
|
content = content.replace(/ /g, ' ');
|
||
|
content = content.replace(/&/g, '&');
|
||
|
content = content.replace(/"/g, '"');
|
||
|
content = content.replace(/</g, '<');
|
||
|
content = content.replace(/>/g, '>');
|
||
|
|
||
|
return countDownCharacters([content, maxCharacters]);
|
||
|
});
|