Skip to content

buildURL

buildURL(components) → string · URL

Build a complete URL from its component parts.

  • components (required): object with protocol, host, port?, path?, query?, fragment?
bash
echo '{"host": "api.example.com", "path": "/v2/users"}' \
  | utlx -e 'buildURL({protocol: "https", host: $input.host, path: $input.path, query: {active: "true"}})'
# "https://api.example.com/v2/users?active=true"
utlx
{
  endpoint: buildURL({
    protocol: "https",
    host: $input.apiHost,
    path: concat("/api/v1/", $input.resource),
    query: {format: "json"}
  })
}

C

Released under AGPL-3.0.