Skip to content

Commit a52877f

Browse files
committed
add location set hash tests
1 parent ee327fa commit a52877f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/browser/html/location.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub const Location = struct {
5252
current_url;
5353

5454
const normalized_hash = std.mem.trimStart(u8, hash, "#");
55-
const new_url = try std.fmt.allocPrint(page.arena, "{s}#{s}", .{ base_without_hash, normalized_hash });
55+
const new_url = try std.fmt.allocPrint(page.session.transfer_arena, "{s}#{s}", .{ base_without_hash, normalized_hash });
5656

5757
return page.navigateFromWebAPI(new_url, .{ .reason = .script }, .replace);
5858
}

src/tests/html/location.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@
1313
testing.expectEqual("9582", location.port);
1414
testing.expectEqual("", location.search);
1515
</script>
16+
17+
<script id=location_hash>
18+
location.hash = "#abcdef";
19+
testing.expectEqual("#abcdef", location.hash);
20+
testing.expectEqual('http://localhost:9582/src/tests/html/location.html#abcdef', location.href);
21+
22+
location.hash = "xyzxyz";
23+
testing.expectEqual("#xyzxyz", location.hash);
24+
testing.expectEqual('http://localhost:9582/src/tests/html/location.html#xyzxyz', location.href);
25+
</script>

0 commit comments

Comments
 (0)