fix buffer ranges

This commit is contained in:
Karl Seguin
2025-09-30 09:14:21 +08:00
parent 298f959e13
commit 37fa41b4a2
3 changed files with 12 additions and 8 deletions

View File

@@ -5,9 +5,9 @@
.fingerprint = 0xda130f3af836cea0,
.dependencies = .{
.v8 = .{
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/c25223900587005c9cf13f25e56a7e0be26a533c.tar.gz",
.hash = "v8-0.0.0-xddH6x_DAwBh0gSbFFv1fyiExhExXKzZpbmj5sFH4MRY",
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/b51ed00390101b1fb9dd1ba4650c13f6586d0e24.tar.gz",
.hash = "v8-0.0.0-xddH68vFAwCYTTv4JjcgP7OcXSW7bv3sCKtaJ2SWXjR8",
},
// .v8 = .{ .path = "../zig-v8-fork" }
//.v8 = .{ .path = "../zig-v8-fork" }
},
}

View File

@@ -19,6 +19,7 @@
const std = @import("std");
const log = @import("../../log.zig");
const Env = @import("../env.zig").Env;
const Page = @import("../page.zig").Page;
// https://encoding.spec.whatwg.org/#interface-textdecoder
@@ -69,8 +70,8 @@ pub fn get_fatal(self: *const TextDecoder) bool {
const DecodeOptions = struct {
stream: bool = false,
};
pub fn _decode(self: *TextDecoder, input_: ?[]const u8, opts_: ?DecodeOptions, page: *Page) ![]const u8 {
var str = input_ orelse return "";
pub fn _decode(self: *TextDecoder, str_: ?[]const u8, opts_: ?DecodeOptions, page: *Page) ![]const u8 {
var str = str_ orelse return "";
const opts: DecodeOptions = opts_ orelse .{};
if (self.stream.items.len > 0) {

View File

@@ -47,11 +47,14 @@
</script>
<script id=slice>
const buffer = new ArrayBuffer(4);
const arr1 = new Uint8Array(buffer)
const buf1 = new ArrayBuffer(7);
const arr1 = new Uint8Array(buf1)
arr1[0] = 80;
arr1[1] = 81;
arr1[2] = 82;
arr1[3] = 83;
testing.expectEqual('QR', d3.decode(new Uint8Array(buffer, 1, 2)));
arr1[4] = 84;
arr1[5] = 85;
arr1[6] = 86;
testing.expectEqual('RST', d3.decode(new Uint8Array(buf1, 2, 3)));
</script>