Not sure if I got your idea right... Is that what you meant:
```
var cnt = 0

  urls.foreach(url => urlGroups(SchemeHost(url.getProtocol, url.getHost)) = url :: urlGroups.get(SchemeHost(url.getProtocol, url.getHost)).getOrElse(Nil))

  val renders =  urlGroups.map( keyVal => {
    val urls = keyVal._2

    cnt += 1
    val valName = "uri" + cnt
    if (urls.size > 1 && schemesPortAreSame(urls)) {
      val paths = urls.map(url => url.getPath)
      val longestCommonPath = longestCommonRoot(paths)

      val firstUrl = urls.head
      values = new Value(valName, fast"${protocol(firstUrl)}${firstUrl.getAuthority}$longestCommonPath".toString) :: values

      extractLongestPathUrls(urls, longestCommonPath, valName)
    } else {
      values = new Value(valName, urls.head.getHost) :: values

      extractCommonHostUrls(urls, valName)
    }
  }).flatten.toMap


  private def extractCommonHostUrls(urls: List[URL], valName: String): List[(String, Fastring)] = {
    urls.map(url =>
      (url.toString, fast""""${protocol(url)}${user(url)}" + $valName + ${value(fast"${port(url)}${url.getPath}${query(url)}")}""")
    )
  }

  private def extractLongestPathUrls(urls: List[URL], longestCommonPath: String, valName: String): List[(String, Fastring)] = {
    urls.map(url => {
      val restPath = url.getPath.substring(longestCommonPath.length)
      (url.toString, fast"$valName + ${value(fast"${restPath}${query(url)}")}")
    })
  }
```