mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 21:44:12 +08:00
Trim spaces in getPlainContent, prevent images from loading
fixes #834 closes #963
This commit is contained in:
parent
500cdbbcb3
commit
e41a427a6b
6
framework/core/js/forum/dist/app.js
vendored
6
framework/core/js/forum/dist/app.js
vendored
|
@ -31481,11 +31481,13 @@ System.register('flarum/utils/string', [], function (_export, _context) {
|
|||
_export('slug', slug);
|
||||
|
||||
function getPlainContent(string) {
|
||||
var dom = $('<div/>').html(string.replace(/(<\/p>|<br>)/g, '$1 '));
|
||||
var html = string.replace(/(<\/p>|<br>)/g, '$1 ').replace(/<img\b[^>]*>/ig, ' ');
|
||||
|
||||
var dom = $('<div/>').html(html);
|
||||
|
||||
dom.find(getPlainContent.removeSelectors.join(',')).remove();
|
||||
|
||||
return dom.text();
|
||||
return dom.text().replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user