formatRaw
Function parameters
Parameters
Type definitions in this namespace
Types
Returned value may point into `buffer` or be the original string.
Functions
- getHost
- Returned value may point into `buffer` or be the original string.
- getHostAlloc
- Returned value may point into `buffer` or be the original string.
- percentDecodeBackwards
- Percent decodes all %XX where XX is a valid hex number.
- percentDecodeInPlace
- Percent decodes all %XX where XX is a valid hex number.
- parseAfterScheme
- Parses the URI or returns an error.
- parse
- The return value will contain strings pointing into the original `text`.
- resolveInPlace
- Resolves a URI against a base URI, conforming to
Error sets in this namespace
Error Sets
= 255
Values
- host_name_max
- = 255
Source
Implementation
pub fn formatRaw(component: Component, w: *Writer) Writer.Error!void {
switch (component) {
.raw => |raw| try w.writeAll(raw),
.percent_encoded => |percent_encoded| {
var start: usize = 0;
var index: usize = 0;
while (std.mem.indexOfScalarPos(u8, percent_encoded, index, '%')) |percent| {
index = percent + 1;
if (percent_encoded.len - index < 2) continue;
const percent_encoded_char =
std.fmt.parseInt(u8, percent_encoded[index..][0..2], 16) catch continue;
try w.print("{s}{c}", .{
percent_encoded[start..percent],
percent_encoded_char,
});
start = percent + 3;
index = percent + 3;
}
try w.writeAll(percent_encoded[start..]);
},
}
}