From 918c9b6d8b714085e0570699468a9d51a7692a15 Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Sat, 30 Mar 2024 16:56:44 +0100 Subject: [PATCH 1/3] Fix slug calculation --- src/main/kotlin/fr/shikkanime/utils/StringUtils.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt index 846a45ef..a5df6a3a 100644 --- a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt +++ b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt @@ -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 } } From 9889be5fcd7667dc69b4bdcc3b91a75092a10206 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 08:08:22 +0000 Subject: [PATCH 2/3] Bump io.github.smiley4:ktor-swagger-ui from 2.7.5 to 2.8.0 Bumps [io.github.smiley4:ktor-swagger-ui](https://github.com/SMILEY4/ktor-swagger-ui) from 2.7.5 to 2.8.0. - [Release notes](https://github.com/SMILEY4/ktor-swagger-ui/releases) - [Changelog](https://github.com/SMILEY4/ktor-swagger-ui/blob/develop/HowToRelease.md) - [Commits](https://github.com/SMILEY4/ktor-swagger-ui/compare/2.7.5...2.8.0) --- updated-dependencies: - dependency-name: io.github.smiley4:ktor-swagger-ui dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index ed6e88fd..075f25ae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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" From 857837bf2c0598ee549314d2754ce47f597f96ec Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Mon, 1 Apr 2024 20:18:00 +0200 Subject: [PATCH 3/3] Add more separator onn short name calculation --- src/main/kotlin/fr/shikkanime/utils/StringUtils.kt | 2 +- src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt index a5df6a3a..6a443d09 100644 --- a/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt +++ b/src/main/kotlin/fr/shikkanime/utils/StringUtils.kt @@ -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 -> diff --git a/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt b/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt index 79e3c7c8..4d4dfb08 100644 --- a/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt +++ b/src/test/kotlin/fr/shikkanime/utils/StringUtilsTest.kt @@ -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) -> @@ -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))) } } } \ No newline at end of file