From 925702d315603973ae24f9a26da6349dd83f76ca Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 8 Sep 2021 12:06:23 +0600 Subject: [PATCH] MPPFile#withoutSlashAtTheEnd --- CHANGELOG.md | 2 ++ .../commonMain/kotlin/dev/inmo/micro_utils/common/MPPFile.kt | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 436ec5543a7..bee7a514b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * `Versions`: * `UUID`: `0.3.0` -> `0.3.1` +* `Common`: + * New property `MPPFile#withoutSlashAtTheEnd` ## 0.5.24 diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MPPFile.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MPPFile.kt index c60eb0d6b80..8aada0ca9c7 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MPPFile.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/MPPFile.kt @@ -7,7 +7,7 @@ import kotlin.jvm.JvmInline @JvmInline value class FileName(val string: String) { val name: String - get() = string.takeLastWhile { it != '/' } + get() = withoutSlashAtTheEnd.takeLastWhile { it != '/' } val extension: String get() = name.takeLastWhile { it != '.' } val nameWithoutExtension: String @@ -17,6 +17,8 @@ value class FileName(val string: String) { filename.substring(0, it) } ?: filename } + val withoutSlashAtTheEnd: String + get() = string.dropLastWhile { it == '/' } override fun toString(): String = string }