Documentation
¶
Overview ¶
Package url is the "encoding/url" host module. See std/encoding/register.go for why this and its eight siblings each get their own leaf package instead of living in std's flat root, and how this directory's Module reaches the rest of magus without std importing back down to collect it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = std.Module{ Name: "url", WASM: true, Path: "encoding/url", Doc: "URL percent-encoding, parsing, and building.", Methods: []std.Method{ { Name: "encode", Doc: "Percent-encode s for use in a URL query component.", Args: []std.Arg{{Name: "s", Type: std.TypeString}}, Returns: []std.Ret{{Type: std.TypeString}}, Impl: URLEncode, }, { Name: "decode", Doc: "Decode a percent-encoded URL query component; errors on malformed input.", Args: []std.Arg{{Name: "s", Type: std.TypeString}}, Returns: []std.Ret{{Type: std.TypeString}}, Raises: true, Impl: URLDecode, }, { Name: "parse", Doc: "Parse a URL string into {scheme, host, port, path, query, fragment}; errors on malformed input.", Args: []std.Arg{{Name: "raw_url", Type: std.TypeString}}, Returns: []std.Ret{{Type: std.TypeAnyMap, Object: "URL"}}, Raises: true, Impl: URLParse, }, { Name: "build", Doc: "Build a URL string from a URL object - the same shape parse returns, so the two round-trip. Missing fields are treated as empty.", Args: []std.Arg{{Name: "parts", Type: std.TypeAnyMap, Object: "URL"}}, Returns: []std.Ret{{Type: std.TypeString}}, Impl: URLBuild, }, }, }
Module is the "encoding/url" host module: percent-encoding, plus parsing a URL into its components and building one back out.
Filed under encoding/ rather than Go's net/url because percent-encoding IS a text codec and belongs beside base64 and hex, and because magus has no net/ tree for a single module to justify. parse and build round-trip through the same URL object, so a caller can take a URL apart, change one field, and put it back without string surgery on a query string.
Functions ¶
func Modules ¶
Modules returns this directory's contribution to the encoding module set. See std/encoding/register.go: it aggregates every leaf's Modules() into one slice, which is how a module here reaches std.All()'s callers without std importing this package to collect it.
func URLBuild ¶
URLBuild assembles a URL string from a parts map with keys scheme, host, port, path, query, fragment. Missing keys are treated as empty.
Types ¶
This section is empty.