feed: reduce and censor content that has many newlines
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details

Render newlines as linebreaks is nice, but it can be abused by
adding too many newlines. This change reduces 3 newlines to 2
globally to keep the output somewhat sane.
OFF0 2 years ago
parent 9711ca2ecf
commit ed49e8afa8
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -33,6 +33,7 @@ export function elem(name = 'div', {data, ...props} = {}, children = []) {
export function multilineText(string) {
return string
.trimRight()
.replaceAll(/\n{3,}/g, '\n\n')
.split('\n')
.reduce((acc, next, i) => acc.concat(i === 0 ? next : [elem('br'), next]), []);
}

Loading…
Cancel
Save