input prop testing

This commit is contained in:
sjorsdonkers
2025-05-31 02:33:09 +02:00
parent 275b97948b
commit 19d40845a4
4 changed files with 189 additions and 11 deletions

View File

@@ -110,6 +110,11 @@ pub const URL = struct {
}
return src;
}
if (src.len == 0) {
if (opts.alloc == .always) {
return allocator.dupe(u8, base);
}
}
const protocol_end: usize = blk: {
if (std.mem.indexOf(u8, base, "://")) |protocol_index| {
@@ -256,6 +261,16 @@ test "URL: Stiching src as full path" {
try testing.expectString("https://lightpanda.io/something.js", result);
}
test "URL: Stitching Base & Src URLs (empty src)" {
const allocator = testing.allocator;
const base = "https://www.google.com/xyz/abc/123";
const src = "";
const result = try URL.stitch(allocator, src, base);
defer allocator.free(result);
try testing.expectString("https://www.google.com/xyz/abc/123", result);
}
test "URL: concatQueryString" {
defer testing.reset();
const arena = testing.arena_allocator;