mirror of
https://github.com/flarum/framework.git
synced 2025-05-24 23:59:57 +08:00
Trim spaces in getPlainContent, prevent images from loading
fixes #834 closes #963
This commit is contained in:
@ -34,11 +34,15 @@ export function slug(string) {
|
||||
* @return {String}
|
||||
*/
|
||||
export function getPlainContent(string) {
|
||||
const dom = $('<div/>').html(string.replace(/(<\/p>|<br>)/g, '$1 '));
|
||||
const html = string
|
||||
.replace(/(<\/p>|<br>)/g, '$1 ')
|
||||
.replace(/<img\b[^>]*>/ig, ' ');
|
||||
|
||||
const dom = $('<div/>').html(html);
|
||||
|
||||
dom.find(getPlainContent.removeSelectors.join(',')).remove();
|
||||
|
||||
return dom.text();
|
||||
return dom.text().replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user