diff --git a/src/lib.zig b/src/lib.zig index 87f9dad2a2393fbc23369e0674eaae8e4dae203c..6ad4c8cab4834d130f02c5f5093f5784786dc16a 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -5,10 +5,10 @@ const string = []const u8; const http = @import("apple_pie"); const files = @import("self/files"); const pek = @import("pek"); -const uri = @import("uri"); const zfetch = @import("zfetch"); const json = @import("json"); const extras = @import("extras"); +const UrlValues = @import("UrlValues"); const Base = @This(); pub const Provider = struct { @@ -350,33 +350,3 @@ pub fn pek_domain(alloc: std.mem.Allocator, writer: std.ArrayList(u8).Writer, p: _ = alloc; try writer.writeAll(p.domain()); } - -// -// - -// TODO make this its own library -const UrlValues = struct { - inner: std.StringArrayHashMap(string), - - pub fn init(alloc: std.mem.Allocator) UrlValues { - return .{ - .inner = std.StringArrayHashMap(string).init(alloc), - }; - } - - pub fn add(self: *UrlValues, key: string, value: string) !void { - try self.inner.putNoClobber(key, value); - } - - pub fn encode(self: UrlValues) !string { - const alloc = self.inner.allocator; - var list = std.ArrayList(u8).init(alloc); - var iter = self.inner.iterator(); - var i: usize = 0; - while (iter.next()) |entry| : (i += 1) { - if (i > 0) try list.writer().writeAll("&"); - try list.writer().print("{s}={s}", .{ entry.key_ptr.*, try uri.escapeString(alloc, entry.value_ptr.*) }); - } - return list.toOwnedSlice(); - } -}; diff --git a/zig.mod b/zig.mod index fc9327b3dbd4b901db398baa1e26d400c1679e35..bd68f1a95ccd9b506307bf911f957d33c5ed1ae5 100644 --- a/zig.mod +++ b/zig.mod @@ -8,7 +8,7 @@ files: dependencies: - src: git https://github.com/Luukdegram/apple_pie - src: git https://github.com/nektro/zig-pek - - src: git https://github.com/MasterQ32/zig-uri - src: git https://github.com/truemedian/zfetch - src: git https://github.com/nektro/zig-json - src: git https://github.com/nektro/zig-extras + - src: git https://github.com/nektro/zig-UrlValues diff --git a/zigmod.lock b/zigmod.lock deleted file mode 100644 index 0cfbf08886fca9a91cb753ec8734c84fcbe52c9f..0000000000000000000000000000000000000000 --- a/zigmod.lock +++ /dev/null @@ -1 +0,0 @@ -2