Callers to page.navigate ensure URL is properly encoded.

Follow up to https://github.com/lightpanda-io/browser/pull/1646

The encodeURL (renamed to ensureEncoded and exposed in this commit) already
handled already-encoded URLs, so this was largely a matter of exposing the
functionality.

The reason this isn't baked directly into Page.navigate is that, in some places
e.g. internal navigation, the URL is already know to be encoded. So it's up
to every caller to make sure they are passing a valid URL to navigate.
This commit is contained in:
Karl Seguin
2026-02-26 12:22:06 +08:00
parent 497d6e80f7
commit 21be3db51f
4 changed files with 147 additions and 16 deletions

View File

@@ -21,6 +21,7 @@ const lp = @import("lightpanda");
const id = @import("../id.zig");
const log = @import("../../log.zig");
const URL = @import("../../browser/URL.zig");
const js = @import("../../browser/js/js.zig");
// TODO: hard coded IDs
@@ -218,8 +219,9 @@ fn createTarget(cmd: anytype) !void {
}
if (!std.mem.eql(u8, "about:blank", params.url)) {
const encoded_url = try URL.ensureEncoded(page.call_arena, params.url);
try page.navigate(
params.url,
encoded_url,
.{ .reason = .address_bar, .kind = .{ .push = null } },
);
}