Fix title='_' case too #685

This commit is contained in:
Emmanuel Engelhart 2022-01-24 08:35:36 +01:00
parent cd412867d9
commit 5a9dbf85ec
No known key found for this signature in database
GPG Key ID: 120B30D020B553D3
1 changed files with 4 additions and 3 deletions

View File

@ -55,11 +55,12 @@
const humanFriendlyTitle = (title) => {
if (typeof title === 'string' && title.length > 0) {
title = title.replace(/_/g, ' ');
if (title.length > 0) {
return htmlEncode(title[0].toUpperCase() + title.slice(1));
} else {
return '';
}
}
return '';
}
function htmlEncode(str) {
return str.replace(/[\u00A0-\u9999<>\&]/gim, (i) => `&#${i.charCodeAt(0)};`);