url/parser

URL parser implementation

Copyright (C) 2025-2026 Trayambak Rai (xtrayambak@disroot.org)

Types

State {.pure.} = enum
  Authority,                ## **See**: https://url.spec.whatwg.org/#scheme-start-state
  SchemeStart,              ## **See**: https://url.spec.whatwg.org/#scheme-state
  Scheme,                   ## **See**: https://url.spec.whatwg.org/#host-state
  Host,                     ## **See**: https://url.spec.whatwg.org/#no-scheme-state
  NoScheme,                 ## **See**: https://url.spec.whatwg.org/#fragment-state
  Fragment,                 ## **See**: https://url.spec.whatwg.org/#relative-state
  RelativeScheme,           ## **See**: https://url.spec.whatwg.org/#relative-slash-state
  RelativeSlash,            ## **See**: https://url.spec.whatwg.org/#file-state
  File,                     ## **See**: https://url.spec.whatwg.org/#file-host-state
  FileHost,                 ## **See**: https://url.spec.whatwg.org/#file-slash-state
  FileSlash,                ## **See**: https://url.spec.whatwg.org/#path-or-authority-state
  PathOrAuthority,          ## **See**: https://url.spec.whatwg.org/#special-authority-ignore-slashes-state
  SpecialAuthorityIgnoreSlashes, ## **See**: https://url.spec.whatwg.org/#special-authority-slashes-state
  SpecialAuthoritySlashes,  ## **See**: https://url.spec.whatwg.org/#special-relative-or-authority-state
  SpecialRelativeOrAuthority, ## **See**: https://url.spec.whatwg.org/#query-state
  Query,                    ## **See**: https://url.spec.whatwg.org/#path-state
  Path,                     ## **See**: https://url.spec.whatwg.org/#path-start-state
  PathStart,                ## **See**: https://url.spec.whatwg.org/#cannot-be-a-base-url-path-state
  OpaquePath,               ## **See**: https://url.spec.whatwg.org/#port-state
  Port
See: https://url.spec.whatwg.org/#authority-state

Consts

FRAGMENT: AsciiSet = {0'u8..32'u8, 34'u8, 60'u8, 62'u8, 96'u8, 126'u8..255'u8}
PATH: AsciiSet = {0'u8..32'u8, 34'u8..35'u8, 60'u8, 62'u8..63'u8, 96'u8,
                  126'u8..255'u8}
PATH_SEGMENT: AsciiSet = {0'u8..32'u8, 34'u8..35'u8, 37'u8, 47'u8, 60'u8,
                          62'u8..63'u8, 96'u8, 126'u8..255'u8}
QUERY: AsciiSet = {0'u8..32'u8, 34'u8..35'u8, 60'u8, 62'u8, 126'u8..255'u8}
SPECIAL_PATH_SEGMENT: AsciiSet = {0'u8..32'u8, 34'u8..35'u8, 37'u8, 47'u8,
                                  60'u8, 62'u8..63'u8, 92'u8, 96'u8,
                                  126'u8..255'u8}
SPECIAL_QUERY: AsciiSet = {0'u8..32'u8, 34'u8..35'u8, 39'u8, 60'u8, 62'u8,
                           126'u8..255'u8}
USERINFO: AsciiSet = {0'u8..32'u8, 34'u8..35'u8, 47'u8, 58'u8..64'u8,
                      91'u8..94'u8, 96'u8, 124'u8, 126'u8..255'u8}

Procs

func parseURLImpl(input: Input; baseUrl: Option[URL] = none(URL)): Result[URL,
    ParseError]

This is the main routine that handles the parsing of a URL string into its structural representation.

NOTE: It is not intended to be called directly and is part of the private API.