mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
fix buffer ranges
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user