hmrc / url-builder

Micro-library for building URLs from templates and tags

Version Matrix

URL Builder

Build Status Download

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 += Resolver.bintrayRepo("hmrc", "releases")

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


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