mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-14 23:38:57 +00:00
changeLocation on nav
This commit is contained in:
@@ -52,7 +52,7 @@ pub const Location = struct {
|
|||||||
current_url;
|
current_url;
|
||||||
|
|
||||||
const normalized_hash = std.mem.trimStart(u8, hash, "#");
|
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);
|
return page.navigateFromWebAPI(new_url, .{ .reason = .script }, .replace);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1065,7 +1065,15 @@ pub const Page = struct {
|
|||||||
// specifically for this type of lifetime.
|
// specifically for this type of lifetime.
|
||||||
pub fn navigateFromWebAPI(self: *Page, url: []const u8, opts: NavigateOpts, kind: NavigationKind) !void {
|
pub fn navigateFromWebAPI(self: *Page, url: []const u8, opts: NavigateOpts, kind: NavigationKind) !void {
|
||||||
const session = self.session;
|
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.
|
// Force will force a page load.
|
||||||
// Otherwise, we need to check if this is a true navigation.
|
// 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)) {
|
if (try self.url.eqlDocument(&new_url, session.transfer_arena)) {
|
||||||
self.url = new_url;
|
self.url = new_url;
|
||||||
|
try self.window.changeLocation(self.url.raw, self);
|
||||||
|
|
||||||
try session.navigation.updateEntries(stitched_url, kind, self, true);
|
try session.navigation.updateEntries(stitched_url, kind, self, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user