commit 377a8b2a3b408dad4392a97254a7a6bb2d06b200 (tree)
parent 32a1aabff78234b428234189ee1093fb65f85fa3
Author: database64128 <free122448@hotmail.com>
Date: Mon, 25 Aug 2025 16:02:24 +0800
std.net.Ip6Address: format numerical scope id
Diffstat:
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/std/net.zig b/lib/std/net.zig
@@ -747,6 +747,9 @@ pub const Ip6Address = extern struct {
try w.writeAll(":");
}
}
+ if (self.sa.scope_id != 0) {
+ try w.print("%{}", .{self.sa.scope_id});
+ }
try w.print("]:{}", .{port});
}
diff --git a/lib/std/net/test.zig b/lib/std/net/test.zig
@@ -73,7 +73,7 @@ test "parse and render IPv6 addresses" {
"2001:db8::",
"::1234:5678",
"2001:db8::1234:5678",
- "ff01::fb",
+ "ff01::fb%1234",
"::ffff:123.5.123.5",
};
for (ips, 0..) |ip, i| {