Skip to content

parseURL

parseURL(url) → object · URL

Parse a URL string into its components (protocol, host, port, path, query, fragment).

  • url (required): the URL string to parse
bash
echo '{"url": "https://example.com:8080/api/v1?key=abc#section"}' | utlx -e 'parseURL($input.url)'
# {"protocol": "https", "host": "example.com", "port": 8080,
#  "path": "/api/v1", "query": "key=abc", "fragment": "section"}
utlx
let parts = parseURL($input.endpoint)
{
  host: parts.host,
  isSecure: parts.protocol == "https"
}

Released under AGPL-3.0.