From 67cc2be817409ad9bc4317bbba3a57bdbaaa8d38 Mon Sep 17 00:00:00 2001 From: Halil Durak Date: Thu, 25 Jun 2026 17:58:08 +0300 Subject: [PATCH] `URL.zig`: update tests --- src/browser/URL.zig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/browser/URL.zig b/src/browser/URL.zig index 5dcddcae5..fc78e5a3e 100644 --- a/src/browser/URL.zig +++ b/src/browser/URL.zig @@ -1667,3 +1667,28 @@ test "URL: resolve path scheme" { } } } + +test "URL: resolveNavigation defaults a schemeless host to http (curl-like)" { + defer testing.reset(); + + const Case = struct { + url: [:0]const u8, + expected: [:0]const u8, + }; + + const cases = [_]Case{ + // Schemeless input (the regression): assume http://, like curl. + .{ .url = "lightpanda.io", .expected = "http://lightpanda.io/" }, + .{ .url = "example.com/path?q=1", .expected = "http://example.com/path?q=1" }, + // An explicit scheme is preserved, not double-prefixed. + .{ .url = "https://example.com/x", .expected = "https://example.com/x" }, + .{ .url = "http://example.com/", .expected = "http://example.com/" }, + // Non-http absolute URLs still parse as-is. + .{ .url = "about:blank", .expected = "about:blank" }, + }; + + for (cases) |case| { + const result = try resolveNavigation(testing.arena_allocator, case.url, .{}); + try testing.expectString(case.expected, result); + } +}