diff --git a/src/browser/html/location.zig b/src/browser/html/location.zig
index 0e12f933..31be5a6b 100644
--- a/src/browser/html/location.zig
+++ b/src/browser/html/location.zig
@@ -52,7 +52,7 @@ pub const Location = struct {
current_url;
const normalized_hash = std.mem.trimStart(u8, hash, "#");
- const new_url = try std.fmt.allocPrint(page.session.transfer_arena, "{s}#{s}", .{ base_without_hash, normalized_hash });
+ const new_url = try std.fmt.allocPrint(page.arena, "{s}#{s}", .{ base_without_hash, normalized_hash });
return page.navigateFromWebAPI(new_url, .{ .reason = .script }, .replace);
}
diff --git a/src/browser/page.zig b/src/browser/page.zig
index 579dd6d5..195fc251 100644
--- a/src/browser/page.zig
+++ b/src/browser/page.zig
@@ -1065,7 +1065,15 @@ pub const Page = struct {
// specifically for this type of lifetime.
pub fn navigateFromWebAPI(self: *Page, url: []const u8, opts: NavigateOpts, kind: NavigationKind) !void {
const session = self.session;
- const stitched_url = try URL.stitch(session.transfer_arena, url, self.url.raw, .{ .alloc = .always });
+ const stitched_url = try URL.stitch(
+ session.transfer_arena,
+ url,
+ self.url.raw,
+ .{
+ .alloc = .always,
+ .null_terminated = true,
+ },
+ );
// Force will force a page load.
// Otherwise, we need to check if this is a true navigation.
@@ -1075,6 +1083,8 @@ pub const Page = struct {
if (try self.url.eqlDocument(&new_url, session.transfer_arena)) {
self.url = new_url;
+ try self.window.changeLocation(self.url.raw, self);
+
try session.navigation.updateEntries(stitched_url, kind, self, true);
return;
}