f100ded / scala-url-builder

A minimalist URL construction library for Scala

GitHub

Build status Coverage Status Maven

Scala URL Builder

Scala URL Builder is a minimalist library for constructing URLs. It's native to Scala, immutable and has no external dependencies

Usage

To get started, add the following dependency into your project:

libraryDependencies += "org.f100ded.scala-url-builder" %% "scala-url-builder" % "LATEST_VERSION"

Replace LATEST_VERSION with the actual release version from the releases page.

And then you can start using the builder:

import org.f100ded.scalaurlbuilder.URLBuilder

val url = URLBuilder(base = "http://localhost/?api_key=foo_bar")
  .withFragment("#ref1")
  .withPathSegments("segment1/segment2/", "segment3/")
  .withQueryParameters(
    "lat" -> "51.509865",
    "lon" -> "-0.118092"
  ).toString

// url = http://localhost/segment1/segment2/segment3/#ref1?api_key=foo_bar&lat=51.509865&lon=-0.118092