Parse, resolve, write and compare URLs the way browsers do, by the URL Standard.
A URL is a plain map of the parts it has:
Every function that takes a URL also takes its text (e.g. a string or a java.net.URI) and parses it as an absolute URL first. For text that doesn't parse, it returns nil.
The functions named after the attributes of JavaScript's URL class (e.g. hostname and pathname) return their values. To set them the way that class's setters do, use with and update.
Parse, resolve, write and compare URLs the way browsers do, by the URL Standard. A URL is a plain map of the parts it has: - :scheme, in lower case, e.g. "https" - :username and :password, percent-encoded, when they aren't empty - :host, as text, e.g. "example.com", "127.0.0.1" or "[::1]" (it can be empty, as in file:///etc/hosts) - :port, a number, unless it's the default of the scheme - :path, a vector of segments, or a string for an opaque path like that of mailto:me@example.com - :query and :fragment, without their ? and # (both can be empty) Every function that takes a URL also takes its text (e.g. a string or a java.net.URI) and parses it as an absolute URL first. For text that doesn't parse, it returns nil. The functions named after the attributes of JavaScript's URL class (e.g. hostname and pathname) return their values. To set them the way that class's setters do, use with and update.
The hosts of URLs by the URL Standard, section 3: domains, IPv4 and IPv6 addresses, opaque hosts and the empty host.
A host is the text that parse returns for it, e.g. "127.0.0.1" or "[::1]". The functions that end in -report also return the validation errors as keywords. Pass them a vector to add the errors to, or nil to skip them.
The hosts of URLs by the URL Standard, section 3: domains, IPv4 and IPv6 addresses, opaque hosts and the empty host. A host is the text that parse returns for it, e.g. "127.0.0.1" or "[::1]". The functions that end in -report also return the validation errors as keywords. Pass them a vector to add the errors to, or nil to skip them.
Domain names in Unicode and in ASCII, by Unicode IDNA Compatibility Processing (UTS #46) of Unicode 18.0.0, revision 36.
The options are those of UTS #46, and default-options holds the ones that the URL Standard uses for the domain of a URL. NFC comes from the platform. A domain is an error rather than a guess when it has a new code point that NFC doesn't leave alone and the platform doesn't know.
Domain names in Unicode and in ASCII, by Unicode IDNA Compatibility Processing (UTS #46) of Unicode 18.0.0, revision 36. The options are those of UTS #46, and default-options holds the ones that the URL Standard uses for the domain of a URL. NFC comes from the platform. A domain is an error rather than a guess when it has a new code point that NFC doesn't leave alone and the platform doesn't know.
Query strings and form bodies in application/x-www-form-urlencoded, by the URL Standard, section 5, with the methods of URLSearchParams from section 6.2.
The pairs are a vector of name-value vectors in order, in which a name can come more than once. Each function also takes a map or any other seq of pairs, e.g. {:q "clojure" :page 2}. A keyword is read as its name (:q as q) and any other value as its text.
Query strings and form bodies in application/x-www-form-urlencoded, by
the URL Standard, section 5, with the methods of URLSearchParams from
section 6.2.
The pairs are a vector of name-value vectors in order, in which a name
can come more than once. Each function also takes a map or any other seq
of pairs, e.g. {:q "clojure" :page 2}. A keyword is read as its name
(:q as q) and any other value as its text.Percent-encoding and percent-decoding, by the percent-encode sets of the URL Standard, section 1.3.
Each set is a predicate of a code point, so a set of your own is a function too, e.g. (some-fn percent/path-set #{0x3B}). Every set of the standard holds the code points above U+007E.
TODO: the encodings other than UTF-8 that HTML passes to the parser for the query of a document in a legacy encoding.
Percent-encoding and percent-decoding, by the percent-encode sets of
the URL Standard, section 1.3.
Each set is a predicate of a code point, so a set of your own is a
function too, e.g. (some-fn percent/path-set #{0x3B}). Every set of the
standard holds the code points above U+007E.
TODO: the encodings other than UTF-8 that HTML passes to the parser for
the query of a document in a legacy encoding.Punycode by RFC 3492, which writes a Unicode label of a domain name in ASCII, e.g. the xn--fa-hia of xn--fa-hia.de for faß.de.
Like most implementations, it limits its numbers to 31 bits.
Punycode by RFC 3492, which writes a Unicode label of a domain name in ASCII, e.g. the xn--fa-hia of xn--fa-hia.de for faß.de. Like most implementations, it limits its numbers to 31 bits.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |