Skip to content

Latest commit

 

History

History
61 lines (54 loc) · 1.12 KB

parse_uri.md

File metadata and controls

61 lines (54 loc) · 1.12 KB

Function

parse_uri — parse a string URI into a structured record

Synopsis

parse_uri(uri: string) -> record

Description

The parse_uri function parses the uri argument that must have the form of a Universal Resource Identifier into a structured URI comprising the parsed components as a Zed record with the following type signature:

{
  scheme: string,
  opaque: string,
  user: string,
  password: string,
  host: string,
  port: uint16,
  path: string,
  query: |{string:[string]}|,
  fragment: string
}

Examples

echo '"scheme://user:password@host:12345/path?a=1&a=2&b=3&c=#fragment"' |
  super -Z -c 'yield parse_uri(this)' -

=>

{
    scheme: "scheme",
    opaque: null (string),
    user: "user",
    password: "password",
    host: "host",
    port: 12345 (uint16),
    path: "/path",
    query: |{
        "a": [
            "1",
            "2"
        ],
        "b": [
            "3"
        ],
        "c": [
            ""
        ]
    }|,
    fragment: "fragment"
}