Loading...
Searching...
No Matches
urlparser Namespace Reference

Namespaces

namespace  detail
 The library's Public Suffix List matcher.
 
namespace  idna
 IDNA (Internationalized Domain Names in Applications) support.
 
namespace  percent_codec
 Percent-encoding (RFC 3986 "quote") / percent-decoding ("unquote").
 

Classes

class  host
 hostname, ipv4, or ipv6: whatever a URL's host actually is (RFC 3986's host grammar), wrapped in a uniform API that matches hostname/ipv4/ipv6/url themselves: a constructor that just parses, plus from_url() and str(). More...
 
class  hostname
 A domain name used as a URL's host, e.g. "www.example.com". More...
 
class  ipv4
 An IPv4 address used as a URL's host, e.g. "192.0.2.1". More...
 
class  ipv6
 An IPv6 address used as a URL's host, e.g. "2001:db8::1". More...
 
class  psl
 
class  scp_url
 Parses an SSH "scp-like" address - user@host:path (what scp, rsync, sshfs, and git all accept, e.g. "git@github.com:user/repo.git") - by normalizing it to a standard ssh://user@host/path URI and handing that to url. Not URI syntax per RFC 3986 (that colon is a path separator, not a port), so plain url() either misparses it or throws. More...
 
class  url
 Represents a URL. More...
 
class  version
 Exposes the library version (from the URLPARSER_VERSION_* macros) at runtime, without needing to #include the macros directly. More...
 

Typedefs

using git_url = scp_url
 Alias for scp_url. Most callers reaching for this class are parsing a git remote specifically (its most common real-world use, e.g. "git@github.com:user/repo.git") - scp_url itself is named for the underlying address syntax (shared with scp/rsync/sshfs too), not tied to git, so this alias exists purely so the name at a git-focused call site can say what it's for.
 
using query_params = std::vector< std::string >
 A vector of strings representing query parameters in a URL.
 

Functions

std::string build_search_params (const std::vector< std::pair< std::string, std::string > > &pairs)
 Build an application/x-www-form-urlencoded query string from ordered key/value pairs - the inverse of url::get_search_params() (url::search_params). Matches WHATWG's own query-serialization rules, verified against ada_url.replace_search_params(): a space becomes '+' (not "%20"), the safe/unescaped set is ASCII alphanumeric plus * - . _ only - narrower than percent_codec::unreserved_set(), which also leaves '~' unescaped; a query string does not. A repeated key (multiple pairs with the same first element) writes multiple "key=value" entries, in the order given - this never deduplicates or reorders.
 
std::string build_search_params (const url::search_params &params)
 Convenience overload: build from a url::search_params map (url::get_search_params()'s return type) instead of an ordered pair list. Each key's values are written out in their own vector order, but the keys themselves follow std::unordered_map's iteration order - unspecified, and not guaranteed to match the original query string's key order. Use the vector<pair> overload above when order matters.
 
std::string normalize (std::string_view input)
 Convenience wrapper: url(input).normalized(). Prefer calling .normalized() directly on a url you already have parsed - this just parses one and immediately normalizes it, so it's no faster than doing that yourself, only more convenient for a one-off string-in/string-out call.
 

Variables

constexpr bool DEFAULT_IGNORE_WWW = false
 

Typedef Documentation

◆ git_url

using urlparser::git_url = typedef scp_url

Alias for scp_url. Most callers reaching for this class are parsing a git remote specifically (its most common real-world use, e.g. "git@github.com:user/repo.git") - scp_url itself is named for the underlying address syntax (shared with scp/rsync/sshfs too), not tied to git, so this alias exists purely so the name at a git-focused call site can say what it's for.

◆ query_params

A vector of strings representing query parameters in a URL.

Function Documentation

◆ build_search_params() [1/2]

std::string urlparser::build_search_params ( const std::vector< std::pair< std::string, std::string > > &  pairs)

Build an application/x-www-form-urlencoded query string from ordered key/value pairs - the inverse of url::get_search_params() (url::search_params). Matches WHATWG's own query-serialization rules, verified against ada_url.replace_search_params(): a space becomes '+' (not "%20"), the safe/unescaped set is ASCII alphanumeric plus * - . _ only - narrower than percent_codec::unreserved_set(), which also leaves '~' unescaped; a query string does not. A repeated key (multiple pairs with the same first element) writes multiple "key=value" entries, in the order given - this never deduplicates or reorders.

Parameters
pairsKey/value pairs, in the order they should appear.
Returns
The encoded query string (no leading '?').
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ build_search_params() [2/2]

std::string urlparser::build_search_params ( const url::search_params &  params)

Convenience overload: build from a url::search_params map (url::get_search_params()'s return type) instead of an ordered pair list. Each key's values are written out in their own vector order, but the keys themselves follow std::unordered_map's iteration order - unspecified, and not guaranteed to match the original query string's key order. Use the vector<pair> overload above when order matters.

+ Here is the call graph for this function:

◆ normalize()

std::string urlparser::normalize ( std::string_view  input)
inline

Convenience wrapper: url(input).normalized(). Prefer calling .normalized() directly on a url you already have parsed - this just parses one and immediately normalizes it, so it's no faster than doing that yourself, only more convenient for a one-off string-in/string-out call.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ DEFAULT_IGNORE_WWW

constexpr bool urlparser::DEFAULT_IGNORE_WWW = false
constexpr