Skip to content

Commit d1e519a

Browse files
author
Felix
committed
#49 port link is not correctly parsed when the server url contains user/pass
1 parent f004763 commit d1e519a

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/main/scala/model/model.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import scala.util.Try
1313
*/
1414
case class Connection(url: String) {
1515
import util.StringUtils._
16-
def host = substringBefore(substringAfter(url, "://"), ":").replace("/var/run/docker.sock", "localhost")
16+
def host = substringBeforeLast(substringAfter(url, "://"), ":").replace("/var/run/docker.sock", "localhost")
1717
}
1818

1919
case class DockerMetadata(connectionInfo: String,

src/main/scala/ui/pages/ImagePage.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ object ImagePageRender {
9797

9898
def vdomInfo(imageInfo: ImageInfo, S: State, P: Props, B: Backend) = {
9999
import util.StringUtils._
100-
val imageName = substringBefore(P.image.RepoTags.headOption.getOrElse(""), ":")
100+
val imageName = substringBeforeLast(P.image.RepoTags.headOption.getOrElse(""), ":")
101101
val generalInfo = Map(
102102
"Id" -> P.image.id,
103103
"Name" -> imageName,

src/main/scala/ui/widgets/dialogs/ContainerRequestForm.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ object ContainerRequestForm {
213213
case NoPorts => ""
214214
case CustomPorts => request.HostConfig.PortBindings
215215
.flatMap { case (containerPort, hostPorts) =>
216-
hostPorts.map(h => (substringBefore(containerPort, "/"), h.HostPort))
216+
hostPorts.map(h => (substringBeforeLast(containerPort, "/"), h.HostPort))
217217
}.filter(_._2.nonEmpty).map { case (internal, external) => s"-p $external:$internal" }
218218
.mkString(" ", " ", "")
219219
}

src/main/scala/util/StringUtils.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ object StringUtils {
99
}
1010
}
1111

12-
def substringBefore(s: String, k: String) = {
13-
s.indexOf(k) match {
12+
def substringBeforeLast(s: String, k: String) = {
13+
s.lastIndexOf(k) match {
1414
case -1 => s
1515
case i => s.substring(0, i)
1616
}

0 commit comments

Comments
 (0)