All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scala.coursier.util.WebPage.scala Maven / Gradle / Ivy

There is a newer version: 2.1.18
Show newest version
package coursier.util

private[coursier] object WebPage extends WebPageCompatibility {

  def listElements(url: String, page: String): Iterator[String] =
    listWebPageRawElements(page)
      .collect {
        case elem if elem.nonEmpty =>
          elem
            .stripPrefix(url)
            .stripPrefix(":") // bintray typically prepends these
      }
      .filter { n =>
        lazy val slashIdx = n.indexOf('/')
        n != "./" && n != "../" && n != "." && n != ".." && n != "/" && (slashIdx < 0 || slashIdx == n
          .length - 1)
      }

  def listDirectories(url: String, page: String): Iterator[String] =
    listElements(url, page)
      .filter(_.endsWith("/"))
      .map(s => s.substring(0, s.length - 1))

  def listFiles(url: String, page: String): Iterator[String] =
    listElements(url, page)
      .filter(!_.endsWith("/"))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy