Skip to content

Commit

Permalink
Merge pull request #329 from Shikkanime/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Ziedelth authored Apr 1, 2024
2 parents 25a00eb + 857837b commit 37e940d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
val ktorVersion = "2.3.9"
val ktorSwaggerUiVersion = "2.7.5"
val ktorSwaggerUiVersion = "2.8.0"
val hibernateCoreVersion = "6.4.4.Final"
val ehcacheVersion = "3.10.8"
val glassfishJaxbVersion = "4.0.5"
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/fr/shikkanime/utils/StringUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object StringUtils {

fun getShortName(fullName: String): String {
val regexs = listOf("[-|!].*[-|!]".toRegex(), "Saison \\d*".toRegex(), "\\(\\d*\\)".toRegex())
val separators = listOf(":", ",", "!")
val separators = listOf(":", ",", "!", " so ")
var shortName = fullName

regexs.forEach { regex ->
Expand All @@ -26,8 +26,7 @@ object StringUtils {
val firstPart = split[0].trim()
val lastPart = split.subList(1, split.size).joinToString(" ").trim()

if (lastPart.count { it == ' ' } >= 2 &&
(firstPart.split(" ").size > 1 || firstPart.length > 5)) {
if (lastPart.count { it == ' ' } >= 2 && firstPart.length > 5) {
shortName = firstPart
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class StringUtilsTest {
"KONOSUBA" to "KONOSUBA -God's blessing on this wonderful world!",
"Moi, quand je me réincarne en Slime" to "Moi, quand je me réincarne en Slime",
"Studio Apartment" to "Studio Apartment, Good Lighting, Angel Included",
"I Was Reincarnated as the 7th Prince" to "I Was Reincarnated as the 7th Prince so I Can Take My Time Perfecting My Magical Ability",
"Mushoku Tensei: Jobless Reincarnation" to "Mushoku Tensei: Jobless Reincarnation",
)

list.forEach { (expected, input) ->
Expand All @@ -47,10 +49,11 @@ class StringUtilsTest {
val list = listOf(
"Gloutons & Dragons" to "gloutons-dragons",
"Moi, quand je me réincarne en Slime" to "moi-quand-je-me-reincarne-en-slime",
"I Was Reincarnated as the 7th Prince so I Can Take My Time Perfecting My Magical Ability" to "i-was-reincarnated-as-the-7th-prince",
)

list.forEach { (input, expected) ->
assertEquals(expected, StringUtils.toSlug(input))
assertEquals(expected, StringUtils.toSlug(StringUtils.getShortName(input)))
}
}
}

0 comments on commit 37e940d

Please sign in to comment.