music: strip articles from extremely short names

Strip articles from names that are longer than 2-4 characters, compared
the prior limit of 3-5.

Resolves #440.
This commit is contained in:
Alexander Capehart 2023-05-12 07:01:04 -06:00
parent eb4adcc109
commit 7ba2b1bb41
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -183,9 +183,9 @@ private data class IntelligentKnownName(override val raw: String, override val s
// Strip any english articles like "the" or "an" from the start, as music
// sorting should ignore such when possible.
when {
length > 5 && startsWith("the ", ignoreCase = true) -> substring(4)
length > 4 && startsWith("an ", ignoreCase = true) -> substring(3)
length > 3 && startsWith("a ", ignoreCase = true) -> substring(2)
length > 4 && startsWith("the ", ignoreCase = true) -> substring(4)
length > 3 && startsWith("an ", ignoreCase = true) -> substring(3)
length > 2 && startsWith("a ", ignoreCase = true) -> substring(2)
else -> this
}
}