From 7903d8e99f641c59502517e7918271506251aa1a Mon Sep 17 00:00:00 2001 From: 0xera <56160164+0xera@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:54:12 +0300 Subject: [PATCH] handle case when a package name is empty --- grease/src/main/kotlin/io/deepmedia/tools/grease/files.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grease/src/main/kotlin/io/deepmedia/tools/grease/files.kt b/grease/src/main/kotlin/io/deepmedia/tools/grease/files.kt index 73b9241..2879515 100644 --- a/grease/src/main/kotlin/io/deepmedia/tools/grease/files.kt +++ b/grease/src/main/kotlin/io/deepmedia/tools/grease/files.kt @@ -43,7 +43,7 @@ val File.packageNames: Set if (file.name != "module-info.class") { val cleanedPath = file.path.removePrefix(this.path).removePrefix("/") cleanedPath - .substring(0 until cleanedPath.lastIndexOf('/')) - .replace('/', '.') + .substring(0 until cleanedPath.lastIndexOf('/').coerceAtLeast(0)) + .replace('/', '.').takeIf { it.isNotBlank() } } else null }.toSet() \ No newline at end of file