howdy/url

Pieces of URL handling that connection strings share: the user and password in a scheme://user:password@host/... URL, and the guess a package makes about whether a host is local.

Values

pub fn credentials(
  userinfo: option.Option(String),
) -> Result(option.Option(#(String, option.Option(String))), Nil)

The user and password from a URL’s userinfo, percent-decoded. A URL with no userinfo has no credentials; one with user but no : has no password. An empty user or an escape that does not decode is an error.

url.credentials(Some("ada:s%3Acret")) // -> Ok(Some(#("ada", Some("s:cret"))))
url.credentials(None)                 // -> Ok(None)
pub fn is_local(host: String) -> Bool

Whether a host looks like it is on this machine or a private network: a loopback address, or a name with no dot in it such as a Compose service called db. Packages use this to pick a default of no TLS for local connections and verified TLS for everything else.

✨ Search Document