Skip to content

Commit

Permalink
#49 port link is not correctly parsed when the server url contains us…
Browse files Browse the repository at this point in the history
…er/pass
  • Loading branch information
Felix committed Feb 20, 2017
1 parent f004763 commit d1e519a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/model/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.util.Try
*/
case class Connection(url: String) {
import util.StringUtils._
def host = substringBefore(substringAfter(url, "://"), ":").replace("/var/run/docker.sock", "localhost")
def host = substringBeforeLast(substringAfter(url, "://"), ":").replace("/var/run/docker.sock", "localhost")
}

case class DockerMetadata(connectionInfo: String,
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/ui/pages/ImagePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object ImagePageRender {

def vdomInfo(imageInfo: ImageInfo, S: State, P: Props, B: Backend) = {
import util.StringUtils._
val imageName = substringBefore(P.image.RepoTags.headOption.getOrElse(""), ":")
val imageName = substringBeforeLast(P.image.RepoTags.headOption.getOrElse(""), ":")
val generalInfo = Map(
"Id" -> P.image.id,
"Name" -> imageName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ object ContainerRequestForm {
case NoPorts => ""
case CustomPorts => request.HostConfig.PortBindings
.flatMap { case (containerPort, hostPorts) =>
hostPorts.map(h => (substringBefore(containerPort, "/"), h.HostPort))
hostPorts.map(h => (substringBeforeLast(containerPort, "/"), h.HostPort))
}.filter(_._2.nonEmpty).map { case (internal, external) => s"-p $external:$internal" }
.mkString(" ", " ", "")
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/util/StringUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ object StringUtils {
}
}

def substringBefore(s: String, k: String) = {
s.indexOf(k) match {
def substringBeforeLast(s: String, k: String) = {
s.lastIndexOf(k) match {
case -1 => s
case i => s.substring(0, i)
}
Expand Down

0 comments on commit d1e519a

Please sign in to comment.