std.net.Ip6Address: format numerical scope id

This commit is contained in:
database64128 2025-08-25 16:02:24 +08:00 committed by Matthew Lugg
parent 32a1aabff7
commit 377a8b2a3b
2 changed files with 4 additions and 1 deletions

View File

@ -747,6 +747,9 @@ pub const Ip6Address = extern struct {
try w.writeAll(":"); try w.writeAll(":");
} }
} }
if (self.sa.scope_id != 0) {
try w.print("%{}", .{self.sa.scope_id});
}
try w.print("]:{}", .{port}); try w.print("]:{}", .{port});
} }

View File

@ -73,7 +73,7 @@ test "parse and render IPv6 addresses" {
"2001:db8::", "2001:db8::",
"::1234:5678", "::1234:5678",
"2001:db8::1234:5678", "2001:db8::1234:5678",
"ff01::fb", "ff01::fb%1234",
"::ffff:123.5.123.5", "::ffff:123.5.123.5",
}; };
for (ips, 0..) |ip, i| { for (ips, 0..) |ip, i| {