diff --git a/README.md b/README.md index bb4abcb24b07473ce09360fdffcc65d0e7ab13b2..86083d5a26b582f2fb78207459c25ce7b46b494e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![loc](https://sloc.xyz/github/nektro/zig-whatwg-url) [![license](https://img.shields.io/github/license/nektro/zig-whatwg-url.svg)](https://github.com/nektro/zig-whatwg-url/blob/master/LICENSE) [![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro) -[![Zig](https://img.shields.io/badge/Zig-0.14-f7a41d)](https://ziglang.org/) +[![Zig](https://img.shields.io/badge/Zig-0.15-f7a41d)](https://ziglang.org/) [![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod) A spec-compliant Zig implementation of WHATWG URL. diff --git a/url.zig b/url.zig index 7b78e437509752c533ddfdb3fd1c946631bc6897..3518b6b49adcc18d601c4433d4efac96a1c3bf73 100644 --- a/url.zig +++ b/url.zig @@ -47,7 +47,7 @@ pub const URL = struct { // input is a scalar value string if (!std.unicode.utf8ValidateSlice(input)) return error.InvalidURL; - var inputl = std.ArrayList(u8).init(alloc); + var inputl = std.array_list.Managed(u8).init(alloc); defer inputl.deinit(); try inputl.appendSlice(input); @@ -70,7 +70,7 @@ pub const URL = struct { // we always do utf-8 // 6. - var buffer = std.ArrayList(u8).init(alloc); + var buffer = std.array_list.Managed(u8).init(alloc); defer buffer.deinit(); // 7. @@ -1138,9 +1138,9 @@ pub const SearchParams = struct { return self.inner.len; } - pub fn encode(self: *const SearchParams) !string { + pub fn encode(self: *const SearchParams) ![]u8 { const alloc = self.allocator; - var list = std.ArrayList(u8).init(alloc); + var list = std.array_list.Managed(u8).init(alloc); errdefer list.deinit(); for (self.inner.items(.key), self.inner.items(.value), 0..) |k, v, i| { if (i > 0) try list.writer().writeAll("&"); @@ -1458,7 +1458,7 @@ fn parseHostOpaque(allocator: std.mem.Allocator, input: []const u8) ![]const u8 /// https://url.spec.whatwg.org/#utf-8-percent-encode fn percentEncode(allocator: std.mem.Allocator, input: []const u8, comptime set: fn (u8) bool) ![]u8 { if (!extras.matchesAny(u8, input, set)) return allocator.dupe(u8, input); - var result = std.ArrayList(u8).init(allocator); + var result = std.array_list.Managed(u8).init(allocator); errdefer result.deinit(); try result.ensureUnusedCapacity(input.len); try percentEncodeAL(&result, input, set); @@ -1467,7 +1467,7 @@ fn percentEncode(allocator: std.mem.Allocator, input: []const u8, comptime set: /// https://url.spec.whatwg.org/#string-percent-decode pub fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 { - var result = std.ArrayList(u8).init(allocator); + var result = std.array_list.Managed(u8).init(allocator); errdefer result.deinit(); try result.ensureUnusedCapacity(input.len); try percentDecodeW(result.writer(), input); @@ -1792,7 +1792,7 @@ fn lastcpi(haystack: []const u8) usize { while (haystack[i] & 0xC0 == 0x80) : (i -= 1) {} return i; } -pub fn percentEncodeScalarAL(list: *std.ArrayList(u8), cp: []const u8, comptime set: fn (u8) bool) !void { +pub fn percentEncodeScalarAL(list: *std.array_list.Managed(u8), cp: []const u8, comptime set: fn (u8) bool) !void { if (set(cp[0])) { for (cp) |b| { try list.append('%'); @@ -1815,7 +1815,7 @@ pub fn percentEncodeW(writer: anytype, input: []const u8, comptime set: fn (u8) } } } -pub fn percentEncodeAL(list: *std.ArrayList(u8), input: []const u8, comptime set: fn (u8) bool) !void { +pub fn percentEncodeAL(list: *std.array_list.Managed(u8), input: []const u8, comptime set: fn (u8) bool) !void { var it = std.unicode.Utf8View.initUnchecked(input).iterator(); while (it.nextCodepointSlice()) |sl| { if (set(sl[0])) { @@ -1927,7 +1927,7 @@ fn nthScalarItem(T: type, haystack: []const u8, needle: T, index: usize) []const pub fn ManyArrayList(N: usize, T: type) type { return struct { - list: std.ArrayList(T), + list: std.array_list.Managed(T), lengths: [N]usize, pub fn init(allocator: std.mem.Allocator) @This() {