diff --git a/src/renderer/helpers/utils.js b/src/renderer/helpers/utils.js index 0a4f3d5a8489e..4fde63b77c033 100644 --- a/src/renderer/helpers/utils.js +++ b/src/renderer/helpers/utils.js @@ -616,9 +616,10 @@ export function getVideoParamsFromUrl(url) { /** * This will match sequences of upper case characters and convert them into title cased words. + * This will also match excessive strings of punctionation and convert them to one representative character * @param {string} title the title to process * @param {number} minUpperCase the minimum number of consecutive upper case characters to match - * @returns {string} the title with upper case characters removed + * @returns {string} the title with upper case characters removed and punctuation normalized */ export function toDistractionFreeTitle(title, minUpperCase = 3) { const firstValidCharIndex = (word) => { @@ -634,7 +635,10 @@ export function toDistractionFreeTitle(title, minUpperCase = 3) { } const reg = RegExp(`[\\p{Lu}|']{${minUpperCase},}`, 'ug') - return title.replace(reg, x => capitalizedWord(x.toLowerCase())) + return title + .replaceAll(/!{2,}/g, '!') + .replaceAll(/[!?]{2,}/g, '?') + .replace(reg, x => capitalizedWord(x.toLowerCase())) } export function formatNumber(number, options = undefined) { diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 0289cf6a4ae27..179753781029c 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -451,7 +451,7 @@ Settings: Hide Video Description: Hide Video Description Hide Comments: Hide Comments Hide Profile Pictures in Comments: Hide Profile Pictures in Comments - Display Titles Without Excessive Capitalisation: Display Titles Without Excessive Capitalisation + Display Titles Without Excessive Capitalisation: Display Titles Without Excessive Capitalisation And Punctuation Hide Live Streams: Hide Live Streams Hide Upcoming Premieres: Hide Upcoming Premieres Hide Sharing Actions: Hide Sharing Actions