Constructing URLs often seems simple. There are some problems with
concatenating strings to build a URL:

Certain parts of the URL disallow certain characters

Formatting some parts of the URL is tricky and doing it manually isn’t fun

To make the experience better rfc3986 provides the
URIBuilder class to generate valid
URIReference instances. The
URIBuilder class will handle ensuring that each
component is normalized and safe for real world use.

Let’s build a basic URL with just a scheme and host. First we create an
instance of URIBuilder. Then we call
add_scheme() and
add_host() with the scheme and host
we want to include in the URL. Then we convert our builder object into
a URIReference and call
unsplit().

rfc3986 makes adding authentication credentials convenient. It takes care of
making the credentials URL safe. There are some characters someone might want
to include in a URL that are not safe for the authority component of a URL.