hmrc / url-builder   2.1.0-1-g82e8e6e

Apache License 2.0 GitHub

Micro-library for building URLs from templates and tags

Scala versions: 2.11

URL Builder

This library is now deprecated.

Either inline or create links in HTML.

Micro-library for building URLs from templates and tags.

  • Creates links with settings that are appropriate to the target. See Link's companion object:
Links.toInternalPage            // No SSO, Same Window
Links.toExternalPage            // No SSO, New Window
Links.toPortalPage              // Client-based SSO, Same Window
Links.toInternalPageWithSso     // Server-based SSO, Same Window
  • Constructs parametrized urls based on the tags and corresponding values provided.


  • Link can be used in scala html templates to generate consistent links across a page:
  @{Link.toPortalPage(id = Some("link-id"),
                      url = "http://someserver:8080/something",
                      value = Some("Placeholder text displayed for the link")).toHtml}
  • UrlBuilder can be used to build a URL based on parameters from a (tag, value) map:
                     Seq("<tag1>"->Some("value1"), "<tag2>"->Some("value2"))

would produce the url: http://someserver:8080/something/value1/value2

Adding to your service

Include the following dependency in your SBT build

resolvers += "HMRC-open-artefacts-maven2" at ""

libraryDependencies += "" %% "url-builder" % "x.x.x-play-yy"

Note, from version 3.6.0, only Play 2.8 is supported.

Run the tests and sbt fmt before raising a PR


sbt fmt

Then run the tests and coverage report:

sbt clean coverage test coverageReport

If your build fails due to poor test coverage, DO NOT lower the test coverage threshold, instead inspect the generated report located here on your local repo: /target/scala-2.12/scoverage-report/index.html


This code is open source software licensed under the Apache 2.0 License.