url: improve url format

This commit is contained in:
Pierre Tachoire
2024-05-13 16:06:41 +02:00
parent 8d6ee42096
commit d93a065db9

View File

@@ -67,7 +67,7 @@ pub const URL = struct {
} }
pub fn deinit(self: *URL, alloc: std.mem.Allocator) void { pub fn deinit(self: *URL, alloc: std.mem.Allocator) void {
self.search_params.deinit(); self.search_params.deinit(alloc);
alloc.free(self.rawuri); alloc.free(self.rawuri);
} }
@@ -90,9 +90,9 @@ pub const URL = struct {
.scheme = true, .scheme = true,
.authentication = true, .authentication = true,
.authority = true, .authority = true,
.path = true, .path = self.uri.path.len > 0,
.query = true, .query = self.uri.query != null and self.uri.query.?.len > 0,
.fragment = true, .fragment = self.uri.fragment != null and self.uri.fragment.?.len > 0,
}, buf.writer()); }, buf.writer());
return try buf.toOwnedSlice(); return try buf.toOwnedSlice();
} }