pub fn writeToStream(uri: *const Uri, writer: *Writer, flags: Format.Flags) Writer.Error!void 267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308pub fn writeToStream(uri: *const Uri, writer: *Writer, flags: Format.Flags) Writer.Error!void {
if (flags.scheme) {
try writer.print("{s}:", .{uri.scheme});
if (flags.authority and uri.host != null) {
try writer.writeAll("//");
}
}
if (flags.authority) {
if (flags.authentication and uri.host != null) {
if (uri.user) |user| {
try user.formatUser(writer);
if (uri.password) |password| {
try writer.writeByte(':');
try password.formatPassword(writer);
}
try writer.writeByte('@');
}
}
if (uri.host) |host| {
try host.formatHost(writer);
if (flags.port) {
if (uri.port) |port| try writer.print(":{d}", .{port});
}
}
}
if (flags.path) {
const uri_path: Component = if (uri.path.isEmpty()) .{ .percent_encoded = "/" } else uri.path;
try uri_path.formatPath(writer);
if (flags.query) {
if (uri.query) |query| {
try writer.writeByte('?');
try query.formatQuery(writer);
}
}
if (flags.fragment) {
if (uri.fragment) |fragment| {
try writer.writeByte('#');
try fragment.formatFragment(writer);
}
}
}
}