URLs, and the hosts that they name, the same way on both platforms.
This covers percent-encoding and query strings, a URL made absolute against the document that it's in, as a browser does it, and the scheme and the origin of a URL. It also tells whether the host of a URL is on the public internet, which is what a request that a stranger chose must check.
URLs are parsed by whatwg-url, which implements the URL Standard, so a host is read as a browser reads it, e.g. 0x7f.1 as 127.0.0.1.
URLs, and the hosts that they name, the same way on both platforms. This covers percent-encoding and query strings, a URL made absolute against the document that it's in, as a browser does it, and the scheme and the origin of a URL. It also tells whether the host of a URL is on the public internet, which is what a request that a stranger chose must check. URLs are parsed by whatwg-url, which implements the URL Standard, so a host is read as a browser reads it, e.g. 0x7f.1 as 127.0.0.1.
(absolute-url base url)The url made absolute against base, the URL of the document that
it's in, as a browser does it. Nil when one of them doesn't read as a
URL.
A path, a path from the root, a query alone or a URL without a scheme resolves against the base. An absolute URL stays as it is.
A base with an opaque path, such as a mailto URL, takes only a fragment.
An empty url names the document itself. A path doesn't go above the
root, so ../x in a document at the root is /x.
The `url` made absolute against `base`, the URL of the document that it's in, as a browser does it. Nil when one of them doesn't read as a URL. A path, a path from the root, a query alone or a URL without a scheme resolves against the base. An absolute URL stays as it is. A base with an opaque path, such as a mailto URL, takes only a fragment. An empty `url` names the document itself. A path doesn't go above the root, so ../x in a document at the root is /x.
(host url)The host of the http or https URL url, in lower case.
The host of the http or https URL `url`, in lower case.
(ip-address s)The bytes of the IP address that the text s writes, as numbers, or
nil for anything else, e.g. a name or a hash.
An IPv4 address has four, and an IPv6 address sixteen. The text of an IPv6 address can have the brackets that a URL puts around it.
The bytes of the IP address that the text `s` writes, as numbers, or nil for anything else, e.g. a name or a hash. An IPv4 address has four, and an IPv6 address sixteen. The text of an IPv6 address can have the brackets that a URL puts around it.
(legal-url url)The url as the URL Standard writes it, which is what the client of
each platform gets, so that it reads the host that public? checked. On
the JVM each character that java.net.URI can't take is percent-encoded
as UTF-8 too, e.g. a bracket in the path, or a percent sign that starts
no escape.
A URL that's written so already comes back unchanged. A host with letters outside ASCII gets the ASCII form of IDNA. Text that isn't a URL stays as it is, but for the encoding on the JVM.
The `url` as the URL Standard writes it, which is what the client of each platform gets, so that it reads the host that public? checked. On the JVM each character that java.net.URI can't take is percent-encoded as UTF-8 too, e.g. a bracket in the path, or a percent sign that starts no escape. A URL that's written so already comes back unchanged. A host with letters outside ASCII gets the ASCII form of IDNA. Text that isn't a URL stays as it is, but for the encoding on the JVM.
(origin url)The scheme, host and port of the http or https URL url as a vector,
as the URL standard and browsers read them. Nil for another URL, and for
a URL without a host.
The host is in lower case, and a name with letters outside ASCII is in the ASCII form of IDNA. When the URL names no port, the port is the one of the scheme.
The scheme, host and port of the http or https URL `url` as a vector, as the URL standard and browsers read them. Nil for another URL, and for a URL without a host. The host is in lower case, and a name with letters outside ASCII is in the ASCII form of IDNA. When the URL names no port, the port is the one of the scheme.
(parts s)The parts of the URL s as it's written, before a parser tidies them,
as a map of :scheme, :authority, :userinfo, :host, :port, :path, :query
and :fragment, each nil when the URL has none, or nil when s has no
scheme. The scheme is in lower case, and the rest is as written, e.g. a
port of 443 for https, or a .. segment in the path, percent-encoded or
not, for a check of the URL rather than a request.
The parts of the URL `s` as it's written, before a parser tidies them, as a map of :scheme, :authority, :userinfo, :host, :port, :path, :query and :fragment, each nil when the URL has none, or nil when `s` has no scheme. The scheme is in lower case, and the rest is as written, e.g. a port of 443 for https, or a .. segment in the path, percent-encoded or not, for a check of the URL rather than a request.
(percent-decode s)The string s with its percent-encoding undone. A plus sign stays a
plus sign, a % that starts no escape stays as it is, and bytes that
aren't UTF-8 become U+FFFD, rather than throwing.
The string `s` with its percent-encoding undone. A plus sign stays a plus sign, a % that starts no escape stays as it is, and bytes that aren't UTF-8 become U+FFFD, rather than throwing.
(percent-encode s)The string s percent-encoded for a query string, the same way on both
platforms. Spaces become %20, not +, and letters, digits and the marks
The string `s` percent-encoded for a query string, the same way on both platforms. Spaces become %20, not +, and letters, digits and the marks - _ . ! ~ * ' ( ) stay as they are.
(public-name? host)Whether the domain name host is a name of the public internet.
Such a name has a dot in it, not counting a dot at its end. It also doesn't stay on a local network, as localhost, .local, .internal and .home.arpa do. A host whose last part is a number isn't a name but an IPv4 address, as a browser reads it, e.g. 10.0.0.1 or 0x7f.0.0.1.
Whether the domain name `host` is a name of the public internet. Such a name has a dot in it, not counting a dot at its end. It also doesn't stay on a local network, as localhost, .local, .internal and .home.arpa do. A host whose last part is a number isn't a name but an IPv4 address, as a browser reads it, e.g. 10.0.0.1 or 0x7f.0.0.1.
(public? url)Whether the host of the http or https URL url is on the public
internet rather than on the network of the app or of its device.
On the JVM each address that the name resolves to must be public, and a name that doesn't resolve isn't. In ClojureScript the name must have a dot in it and mustn't be localhost or a name under .localhost, .local, .internal or .home.arpa. When send! asks in Node, each address of the name must be public too.
Whether the host of the http or https URL `url` is on the public internet rather than on the network of the app or of its device. On the JVM each address that the name resolves to must be public, and a name that doesn't resolve isn't. In ClojureScript the name must have a dot in it and mustn't be localhost or a name under .localhost, .local, .internal or .home.arpa. When send! asks in Node, each address of the name must be public too.
(query-pairs s)The parameters of the query string s, decoded, as pairs of a name and
a value in their order, a name that comes twice twice. A plus sign is a
space, as in the body of a form, and a name without = has a nil value.
Use this rather than query-params where a repeated parameter must be refused, as RFC 6749, section 3.1, has an OAuth server do.
The parameters of the query string `s`, decoded, as pairs of a name and a value in their order, a name that comes twice twice. A plus sign is a space, as in the body of a form, and a name without = has a nil value. Use this rather than query-params where a repeated parameter must be refused, as RFC 6749, section 3.1, has an OAuth server do.
(query-params s)The parameters of the query string s, decoded, by name. A plus sign
is a space, as in the body of a form. Of a name that comes twice, the
last value counts.
The parameters of the query string `s`, decoded, by name. A plus sign is a space, as in the body of a form. Of a name that comes twice, the last value counts.
(query-string params)The query string for params, with keys and values URL-encoded and nil
values left out. A true value becomes the bare flag that some APIs take.
The query string for `params`, with keys and values URL-encoded and nil values left out. A true value becomes the bare flag that some APIs take.
(same-origin? a b)Whether the URLs a and b have the same scheme, host and port. False
when a URL has no host.
Whether the URLs `a` and `b` have the same scheme, host and port. False when a URL has no host.
(scheme s)The scheme of the URL s in lower case, or nil for a relative URL. It's
read as a browser reads it: without the tabs and line breaks in it, and
without the spaces and control characters in front.
The scheme of the URL `s` in lower case, or nil for a relative URL. It's read as a browser reads it: without the tabs and line breaks in it, and without the spaces and control characters in front.
(split-credentials url)The url without the user name and the password that it holds, and
those as credentials for authorization, as a pair. The credentials are
nil when the URL holds none.
A URL such as https://user:pass@host/feed.xml holds them. Use this when you keep a URL, to keep the password apart from the address, since an address travels into files, logs and messages.
The password is a hidden text, which the printer doesn't show.
The `url` without the user name and the password that it holds, and those as credentials for authorization, as a pair. The credentials are nil when the URL holds none. A URL such as https://user:pass@host/feed.xml holds them. Use this when you keep a URL, to keep the password apart from the address, since an address travels into files, logs and messages. The password is a hidden text, which the printer doesn't show.
(web-url? s)Whether s is an http or https URL with a host.
Whether `s` is an http or https URL with a host.
(with-query url params)The url with params added to its query, encoded as in a query
string. The parameters go after those that the URL has, and before its
fragment.
The `url` with `params` added to its query, encoded as in a query string. The parameters go after those that the URL has, and before its fragment.
(without-trailing-slashes url)The url without the slashes at its end, e.g. the root of an API that
paths are joined to, in a time that grows with its length alone.
The `url` without the slashes at its end, e.g. the root of an API that paths are joined to, in a time that grows with its length alone.
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 |