Skip to content

Commit

Permalink
Adding test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dravenk committed Aug 19, 2024
1 parent c6fd14d commit 5a5f27c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/url.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub fn parseUrl(self: *URL, text: []const u8) ParseError!*URL {
if ((reader.peek() orelse 0) == '?') { // query part
std.debug.assert(reader.get().? == '?');
self.query = reader.readUntil(isQuerySeparator);
self.querymap = parseQuery(self.query.?);
}

if ((reader.peek() orelse 0) == '#') { // fragment part
Expand Down
6 changes: 5 additions & 1 deletion src/url_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ test "RFC example 1" {
var url = URL.init(.{});
const result = url.parseUrl(text) catch return;
try testing.expectEqualStrings("/over/there", result.path);
try testing.expectEqualStrings("name=ferret", result.query.?);
try testing.expectEqualStrings("name=ferret", @constCast(result.query.?));
try testing.expectEqualStrings("nose", result.fragment.?);

var qm = url.querymap.?;
defer qm.deinit();
try testing.expectEqualStrings("ferret", qm.get("name").?);
}

0 comments on commit 5a5f27c

Please sign in to comment.