-
Notifications
You must be signed in to change notification settings - Fork 4
The net url library
The url library parses URLs and implements query escaping. See RFC 3986. This package generally follows RFC 3986, except where it deviates for compatibility reasons. RFC 6874 is followed for IPv6 zone literals.
Data structure containing the name and password of a user.
Url = struct (scheme string, opaque string, user UserInfo, host string, path string, rawPath string, omitHost bool, forceQuery bool, rawQuery string, fragment string, rawFragment string)
Data structure containing a parsed URL.
Encodes the map into “URL encoded” form ("bar=baz&foo=quux") sorted by key.
Returns the escaped form of u[fragment].
Returns the escaped form of u[path].
Returns the hostname of the Url.
Tests whether the Url is absolute.
joinPath with a Url as the first parameter returns a new URL with the provided path elements joined to any existing path and the resulting path cleaned of any ./ or ../ elements. Any sequences of multiple / characters will be reduced to a single /. Path elements must already be in escaped form, as produced by pathEscape.
joinPath with a string as the first parameter returns a URL string with the provided path elements joined to the existing path of base and the resulting path cleaned of any ./ or ../ elements. Path elements must already be in escaped form, as produced by pathEscape.
Parses a raw url into a URL structure. The url may be relative (a path, without a host) or absolute (starting with a scheme). Trying to parse a hostname and path without a scheme is invalid but may not necessarily return an error, due to parsing ambiguities.
Parses a string into a Url in the context of v. The URL may be relative or absolute.
ParseQuery parses the URL-encoded query string and returns a map listing the values specified for each key. parseQuery always returns a non-nil map containing all the valid query parameters found. If the string is ill-formed, the function will return an error describing the first decoding problem encountered. The query parameter is expected to be a list of key=value settings separated by ampersands. A setting without an equals sign is interpreted as a key set to an empty value. Settings containing a non-URL-encoded semicolon are considered invalid.
ParseRequestURI parses a raw url into a Url structure. It assumes that the url was received in an HTTP request, so the url is interpreted only as an absolute URI or an absolute path. The string url is assumed not to have a #fragment suffix. (Web browsers strip #fragment before sending the URL to a web server.)
pathEscape escapes the string so it can be safely placed inside a URL path segment, replacing special characters (including /) with %XX sequences as needed.
pathUnescape does the inverse transformation of PathEscape, converting each 3-byte encoded substring of the form "%AB" into the hex-decoded byte 0xAB. It returns an error if any % is not followed by two hexadecimal digits. pathUnescape is identical to queryUnescape except that it does not unescape '+' to ' ' (space).
Returns the port part of u[host], without the leading colon. If u[host] doesn't contain a valid numeric port, port returns an empty string.
query parses the raw query of the Url and returns the corresponding values. It silently discards malformed value pairs. To check errors use parseQuery.
queryEscape escapes the string so it can be safely placed inside a URL query.
queryUnescape does the inverse transformation of queryEscape, converting each 3-byte encoded substring of the form "%AB" into the hex-decoded byte 0xAB. It returns an error if any % is not followed by two hexadecimal digits.
redacted is like string but replaces any password with "xxxxx". Only the password in u[user] is redacted.
Returns the encoded path?query or opaque?query string that would be used in an HTTP request for u.
Resolves a URI reference to an absolute URI from an absolute base URI u, per RFC 3986 Section 5.2. The URI reference may be relative or absolute.
Reassembles the URL into a valid URL string.
This page is automatically generated from the Pipefish standard library. Any edits made directly to this wiki page will be overwritten the next time the documentation is regenerated.
🧿 Pipefish is distributed under the MIT license. Please steal my code and ideas.
- Getting started
- Language basics
- The type system and built-in functions
- Functional Pipefish
- Encapsulation
- Imperative Pipefish
-
Imports and libraries
- The crypto/aes library
- The crypto/bcrypt library
- The crypto/rand library
- The crypto/rsa library
- The crypto/sha_256 library
- The crypto/sha_512 library
- The database/sql library
- The encoding/base_32 library
- The encoding/base_64 library
- The encoding/csv library
- The encoding/json library
- The files library
- The fmt library
- The html library
- The image library
- The image/bmp library
- The image/color library
- The image/jpeg library
- The image/png library
- The lists library
- The markdown library
- The math library
- The math/big library
- The math/cmplx library
- The math/rand library
- The net/http library
- The net/mail library
- The net/smtp library
- The net/url library
- The os/exec library
- The path library
- The path/filepath library
- The reflect library
- The regexp library
- The strconv library
- The strings library
- The terminal library
- The time library
- The unicode library
- Advanced Pipefish
- Developing in Pipefish
- Deployment
- Appendices