From eddf91fe27990d4d455975093312db436991e8a9 Mon Sep 17 00:00:00 2001 From: 0xera <56160164+0xera@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:34:02 +0300 Subject: [PATCH] Handle empty package names (#20) --- 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