mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Trim spaces in getPlainContent, prevent images from loading
fixes #834 closes #963
This commit is contained in:
parent
6aa017659f
commit
2b9ec71a81
6
js/forum/dist/app.js
vendored
6
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