def getListenUrl()

in gitcommits/src/main/scala/com/gerritforge/analytics/gitcommits/plugin/GerritConfigSupport.scala [10:26]


  def getListenUrl(): Option[String] = {
    val listenUrl = cfg.getString("httpd", null, "listenUrl")
    val portRegex = "(proxy-)?https?://[^:]+:([0-9]+)/(.*)".r
    listenUrl match {
      case portRegex(_, port, path) =>
        val url = s"http://127.0.0.1:$port/$path"
        if (url.endsWith("/")) {
          Some(url.dropRight(1))
        } else {
          Some(url)
        }
      case _ => {
        logger.warn(s"Unable to extract local Gerrit URL from $listenUrl")
        None
      }
    }
  }