From 0f182fb17fd7ae798feed0a72f0c40563bf595d0 Mon Sep 17 00:00:00 2001 From: zt515 Date: Mon, 1 Jan 2018 23:53:10 +0800 Subject: [PATCH] Fix: Package list file detection --- app/src/main/java/io/neoterm/component/pm/SourceUtils.kt | 7 +++++-- app/src/test/java/io/neoterm/PackageManagerTest.kt | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/neoterm/component/pm/SourceUtils.kt b/app/src/main/java/io/neoterm/component/pm/SourceUtils.kt index 554f29e..513e6b9 100644 --- a/app/src/main/java/io/neoterm/component/pm/SourceUtils.kt +++ b/app/src/main/java/io/neoterm/component/pm/SourceUtils.kt @@ -40,9 +40,12 @@ object SourceUtils { builder.append(":${url.port}") } - if (url.path != null && url.path.isNotEmpty()) { + val path = url.path + if (path != null && path.isNotEmpty()) { builder.append("_") - builder.append(url.path.substring(1)) // Skip '/' + val fixedPath = path.replace("/", "_") + .substring(1) // skip the last '/' + builder.append(fixedPath) } builder.append("_dists_stable_main_binary-") return builder.toString() diff --git a/app/src/test/java/io/neoterm/PackageManagerTest.kt b/app/src/test/java/io/neoterm/PackageManagerTest.kt index 16ffa6c..836c7af 100644 --- a/app/src/test/java/io/neoterm/PackageManagerTest.kt +++ b/app/src/test/java/io/neoterm/PackageManagerTest.kt @@ -3,6 +3,8 @@ package io.neoterm import io.neoterm.component.pm.PackageComponent import io.neoterm.component.pm.SourceUtils import io.neoterm.frontend.component.ComponentManager +import junit.framework.Assert.assertEquals +import junit.framework.Assert.assertTrue import org.junit.Test import java.io.File @@ -28,4 +30,9 @@ class PackageManagerTest { System.err.println(pm.packages["rcs"]?.description) } + + @Test + fun testReplaceAll() { + assertEquals("/root/boom.sh".replace("/", "_"), "_root_boom.sh") + } } \ No newline at end of file