Uniform Resource Identifier (URI) parsing roughly adhering to https://tools.ietf.org/html/rfc3986. Does not do perfect grammar and character class checking, but should be robust against URIs in the wild.

Fields

scheme: []const u8,
user: ?[]const u8,
password: ?[]const u8,
host: ?[]const u8,
port: ?u16,
path: []const u8,
query: ?[]const u8,
fragment: ?[]const u8,

Functions

fn escapePath(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8

No documentation provided.

fn escapeQuery(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8

No documentation provided.

fn escapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8

Applies URI encoding and replaces all reserved characters with their respective …

Applies URI encoding and replaces all reserved characters with their respective %XX code.

fn escapeStringWithFn(allocator: std.mem.Allocator, input: []const u8, comptime keepUnescaped: fn (u8) bool) std.mem.Allocator.Error![]u8

No documentation provided.

fn format(uri: Uri, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void

No documentation provided.

fn parse(text: []const u8) ParseError!Uri

Parses the URI or returns an error. The return value will contain unescaped str…

Parses the URI or returns an error. The return value will contain unescaped strings pointing into the original text. Each component that is provided, will be non-null.

fn parseWithoutScheme(text: []const u8) ParseError!Uri

Parses the URI or returns an error. This function is not compliant, but is requi…

Parses the URI or returns an error. This function is not compliant, but is required to parse some forms of URIs in the wild. Such as HTTP Location headers. The return value will contain unescaped strings pointing into the original text. Each component that is provided, will be non-null.

fn resolve(Base: Uri, R: Uri, strict: bool, arena: std.mem.Allocator) !Uri

Resolves a URI against a base URI, conforming to RFC 3986, Section 5. arena own…

Resolves a URI against a base URI, conforming to RFC 3986, Section 5. arena owns any memory allocated by this function.

fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8

Parses a URI string and unescapes all %XX where XX is a valid hex number. Otherw…

Parses a URI string and unescapes all %XX where XX is a valid hex number. Otherwise, verbatim copies them to the output.

fn writeEscapedPath(writer: anytype, input: []const u8) !void

No documentation provided.

fn writeEscapedQuery(writer: anytype, input: []const u8) !void

No documentation provided.

fn writeEscapedString(writer: anytype, input: []const u8) !void

No documentation provided.

fn writeEscapedStringWithFn(writer: anytype, input: []const u8, comptime keepUnescaped: fn (u8) bool) @TypeOf(writer).Error!void

No documentation provided.

Error Sets