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, 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.
(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.
The base is a URL with a scheme that can hold a path, so not a mailto
URL. 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. The base is a URL with a scheme that can hold a path, so not a mailto URL. 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 with each character that a URI can't contain
percent-encoded as UTF-8, e.g. a space or a letter outside ASCII.
A bracket in the path is encoded too, because java.net.URI takes none there, and so is a percent sign that starts no escape. An escape stays as it is, so an encoded URL comes back unchanged. A host with letters outside ASCII gets the ASCII form of IDNA.
The `url` with each character that a URI can't contain percent-encoded as UTF-8, e.g. a space or a letter outside ASCII. A bracket in the path is encoded too, because java.net.URI takes none there, and so is a percent sign that starts no escape. An escape stays as it is, so an encoded URL comes back unchanged. A host with letters outside ASCII gets the ASCII form of IDNA.
(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.
(percent-decode s)The string s with its percent-encoding undone. A plus sign stays a
plus sign, and a string with an escape that doesn't decode comes back
as it is, rather than throwing.
The string `s` with its percent-encoding undone. A plus sign stays a plus sign, and a string with an escape that doesn't decode comes back as it is, 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-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.
The parameters of the query string `s`, decoded, by name. A plus sign is a space, as in the body of a form.
(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.
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 |