mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-20 01:17:45 +02:00
Add stripRedudantSpaces
This commit is contained in:
parent
819c524f51
commit
49e4515785
@ -439,6 +439,8 @@ function replaceAccentedChars(str) {
|
|||||||
|
|
||||||
function cleanTitleForCompares(title) {
|
function cleanTitleForCompares(title) {
|
||||||
if (!title) return ''
|
if (!title) return ''
|
||||||
|
title = stripRedundantSpaces(title)
|
||||||
|
|
||||||
// Remove subtitle if there (i.e. "Cool Book: Coolest Ever" becomes "Cool Book")
|
// Remove subtitle if there (i.e. "Cool Book: Coolest Ever" becomes "Cool Book")
|
||||||
let stripped = stripSubtitle(title)
|
let stripped = stripSubtitle(title)
|
||||||
|
|
||||||
@ -452,6 +454,8 @@ function cleanTitleForCompares(title) {
|
|||||||
|
|
||||||
function cleanAuthorForCompares(author) {
|
function cleanAuthorForCompares(author) {
|
||||||
if (!author) return ''
|
if (!author) return ''
|
||||||
|
author = stripRedundantSpaces(author)
|
||||||
|
|
||||||
let cleanAuthor = replaceAccentedChars(author).toLowerCase()
|
let cleanAuthor = replaceAccentedChars(author).toLowerCase()
|
||||||
// separate initials
|
// separate initials
|
||||||
cleanAuthor = cleanAuthor.replace(/([a-z])\.([a-z])/g, '$1. $2')
|
cleanAuthor = cleanAuthor.replace(/([a-z])\.([a-z])/g, '$1. $2')
|
||||||
@ -459,3 +463,7 @@ function cleanAuthorForCompares(author) {
|
|||||||
cleanAuthor = cleanAuthor.replace(/(?<=\w\w)(\s+[a-z]\.?)+(?=\s+\w\w)/g, '')
|
cleanAuthor = cleanAuthor.replace(/(?<=\w\w)(\s+[a-z]\.?)+(?=\s+\w\w)/g, '')
|
||||||
return cleanAuthor
|
return cleanAuthor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripRedundantSpaces(str) {
|
||||||
|
return str.replace(/\s+/g, ' ').trim()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user