Lightpanda: the headless browser designed for AI and automation
Replace deprecated std.mem.indexOf* with find*
Adrià Arrufatc3083725c54a
diff --git a/src/Config.zig b/src/Config.zigindex 2b2b8a402..21dc0c5fb 100644--- a/src/Config.zig+++ b/src/Config.zig@@ -1046,7 +1046,7 @@ pub const HttpHeaders = struct {var it = std.mem.splitScalar(u8, header, ',');while (it.next()) |item| {- const end = std.mem.indexOfScalar(u8, item, ';') orelse item.len;+ const end = std.mem.findScalar(u8, item, ';') orelse item.len;const tag = std.mem.trim(u8, item[0..end], " \t");if (tag.len > 0) {try languages.append(allocator, tag);@@ -1104,7 +1104,7 @@ pub const HttpHeaders = struct {/// last resort, with descending q values. `buf` must hold the longest/// output for a tag that passed validateLocale (35 + 24 bytes).fn acceptLanguageFor(buf: *[64]u8, tag: []const u8) []const u8 {- const primary = tag[0 .. std.mem.indexOfScalar(u8, tag, '-') orelse tag.len];+ const primary = tag[0 .. std.mem.findScalar(u8, tag, '-') orelse tag.len];var w: std.Io.Writer = .fixed(buf);w.writeAll(tag) catch unreachable;var q: u8 = 9;diff --git a/src/SemanticTree.zig b/src/SemanticTree.zigindex 76cb4b07f..ebe2528d9 100644--- a/src/SemanticTree.zig+++ b/src/SemanticTree.zig@@ -293,7 +293,7 @@ fn visitNode(}if (std.mem.eql(u8, role, "StaticText") and node._parent != null) {- if (parent_name != null and name != null and std.mem.indexOf(u8, parent_name.?, name.?) != null) {+ if (parent_name != null and name != null and std.mem.find(u8, parent_name.?, name.?) != null) {should_visit = false;}}@@ -784,7 +784,7 @@ test "SemanticTree backendDOMNodeId" {const json_str = try std.json.Stringify.valueAlloc(testing.allocator, st, .{});defer testing.allocator.free(json_str);- try testing.expect(std.mem.indexOf(u8, json_str, "\"backendDOMNodeId\":") != null);+ try testing.expect(std.mem.find(u8, json_str, "\"backendDOMNodeId\":") != null);}test "SemanticTree max_depth" {@@ -803,7 +803,7 @@ test "SemanticTree max_depth" {try st.textStringify(&aw.writer);const text_str = aw.written();- try testing.expect(std.mem.indexOf(u8, text_str, "other") == null);+ try testing.expect(std.mem.find(u8, text_str, "other") == null);}test "SemanticTree: deep nesting doesn't overflow the native stack" {@@ -832,7 +832,7 @@ test "SemanticTree: deep nesting doesn't overflow the native stack" {const json_str = try std.json.Stringify.valueAlloc(testing.allocator, st, .{});defer testing.allocator.free(json_str);- try testing.expect(std.mem.indexOf(u8, json_str, "\"role\":\"link\",\"name\":\"deep\"") != null);+ try testing.expect(std.mem.find(u8, json_str, "\"role\":\"link\",\"name\":\"deep\"") != null);try testing.expectEqual(depth, std.mem.count(u8, json_str, "/g[1]"));try testing.expect(std.mem.endsWith(u8, json_str, "/text()[1]\",\"nodeType\":3,\"nodeValue\":\"deep\",\"children\":[]}]}"));}diff --git a/src/TestHTTPServer.zig b/src/TestHTTPServer.zigindex 2613e9205..e005c085b 100644--- a/src/TestHTTPServer.zig+++ b/src/TestHTTPServer.zig@@ -113,7 +113,7 @@ pub fn sendFile(req: *std.http.Server.Request, file_path: []const u8) !void {var url_buf: [1024]u8 = undefined;var fba = std.heap.FixedBufferAllocator.init(&url_buf);var unescaped_file_path = try URL.unescape(fba.allocator(), file_path);- if (std.mem.indexOfScalarPos(u8, unescaped_file_path, 0, '?')) |pos| {+ if (std.mem.findScalarPos(u8, unescaped_file_path, 0, '?')) |pos| {unescaped_file_path = unescaped_file_path[0..pos];}const file = std.Io.Dir.cwd().openFile(lp.io, unescaped_file_path, .{}) catch |err| switch (err) {diff --git a/src/TestWSServer.zig b/src/TestWSServer.zigindex 9f889ce60..bd14cc18b 100644--- a/src/TestWSServer.zig+++ b/src/TestWSServer.zig@@ -98,9 +98,9 @@ fn handleClient(client: posix.socket_t) void {// Find Sec-WebSocket-Keyconst key_header = "Sec-WebSocket-Key: ";- const key_start = std.mem.indexOf(u8, request, key_header) orelse return;+ const key_start = std.mem.find(u8, request, key_header) orelse return;const key_line_start = key_start + key_header.len;- const key_end = std.mem.indexOfScalarPos(u8, request, key_line_start, '\r') orelse return;+ const key_end = std.mem.findScalarPos(u8, request, key_line_start, '\r') orelse return;const key = request[key_line_start..key_end];// Capture the request's Cookie header value (if any) so the test@@ -111,9 +111,9 @@ fn handleClient(client: posix.socket_t) void {var cookie_buf: [4096]u8 = undefined;var cookie_len: usize = 0;const cookie_header = "Cookie: ";- if (std.mem.indexOf(u8, request, cookie_header)) |cookie_start| {+ if (std.mem.find(u8, request, cookie_header)) |cookie_start| {const value_start = cookie_start + cookie_header.len;- const value_end = std.mem.indexOfScalarPos(u8, request, value_start, '\r') orelse value_start;+ const value_end = std.mem.findScalarPos(u8, request, value_start, '\r') orelse value_start;const value = request[value_start..value_end];cookie_len = @min(value.len, cookie_buf.len);@memcpy(cookie_buf[0..cookie_len], value[0..cookie_len]);@@ -125,9 +125,9 @@ fn handleClient(client: posix.socket_t) void {var origin_buf: [1024]u8 = undefined;var origin_len: usize = 0;const origin_header = "\r\nOrigin: ";- if (std.mem.indexOf(u8, request, origin_header)) |origin_start| {+ if (std.mem.find(u8, request, origin_header)) |origin_start| {const value_start = origin_start + origin_header.len;- const value_end = std.mem.indexOfScalarPos(u8, request, value_start, '\r') orelse value_start;+ const value_end = std.mem.findScalarPos(u8, request, value_start, '\r') orelse value_start;const value = request[value_start..value_end];origin_len = @min(value.len, origin_buf.len);@memcpy(origin_buf[0..origin_len], value[0..origin_len]);@@ -304,7 +304,7 @@ fn handleTextMessage(client: posix.socket_t, payload: []const u8, cookie_header:// Command: close:CODE:REASON - send close frame with specific code/reasonif (std.mem.startsWith(u8, payload, "close:")) {const rest = payload["close:".len..];- if (std.mem.indexOf(u8, rest, ":")) |sep| {+ if (std.mem.find(u8, rest, ":")) |sep| {const code = std.fmt.parseInt(u16, rest[0..sep], 10) catch 1000;const reason = rest[sep + 1 ..];try sendCloseFrame(client, code, reason);diff --git a/src/agent/Agent.zig b/src/agent/Agent.zigindex a605c13c3..42518183d 100644--- a/src/agent/Agent.zig+++ b/src/agent/Agent.zig@@ -2112,7 +2112,7 @@ test "savePrompt: save instructions followed by the rendered script skill" {try std.testing.expect(std.mem.endsWith(u8, prompt, lp.skill.text()));const revision = savePrompt(true);- try std.testing.expect(std.mem.indexOf(u8, revision, save_revision_note) != null);+ try std.testing.expect(std.mem.find(u8, revision, save_revision_note) != null);try std.testing.expect(std.mem.endsWith(u8, revision, lp.skill.text()));}@@ -2142,7 +2142,7 @@ test "capToolOutput: appends a marker when truncating" {defer if (out.ptr != buf.ptr) ta.free(out);try std.testing.expect(std.unicode.utf8ValidateSlice(out));- try std.testing.expect(std.mem.indexOf(u8, out, "truncated") != null);+ try std.testing.expect(std.mem.find(u8, out, "truncated") != null);}test "capToolOutput: extract is exempt from the default cap" {diff --git a/src/agent/js_highlight.zig b/src/agent/js_highlight.zigindex 41272cfac..e80ac7922 100644--- a/src/agent/js_highlight.zig+++ b/src/agent/js_highlight.zig@@ -31,7 +31,7 @@ const StringSpan = struct { end: usize, closed: bool };/// good enough for coloring, not parsing.fn scanString(text: []const u8, start: usize) StringSpan {if (start >= text.len) return .{ .end = start, .closed = false };- const close = std.mem.indexOfScalarPos(u8, text, start + 1, text[start]) orelse+ const close = std.mem.findScalarPos(u8, text, start + 1, text[start]) orelsereturn .{ .end = text.len, .closed = false };return .{ .end = close + 1, .closed = true };}@@ -59,7 +59,7 @@ pub fn nextDollarRef(text: []const u8, from: usize, end: usize, interpolation: bcontinue;}if (interpolation and i + 1 < end and text[i + 1] == '{') {- const close = std.mem.indexOfScalarPos(u8, text[0..end], i + 2, '}');+ const close = std.mem.findScalarPos(u8, text[0..end], i + 2, '}');return .{ .start = i, .end = if (close) |c| c + 1 else end, .kind = .interpolation };}const ref_end = dollarRefEnd(text, i, end);@@ -79,13 +79,13 @@ pub fn tokenize(text: []const u8, state: State, sink: anytype) State {switch (state) {.block_comment => {- const close = std.mem.indexOfPos(u8, text, 0, "*/");+ const close = std.mem.findPos(u8, text, 0, "*/");i = if (close) |p| p + 2 else text.len;if (i > 0) sink.emit(0, i, .comment);if (close == null) return .block_comment;},.template => {- const close = std.mem.indexOfScalarPos(u8, text, 0, '`');+ const close = std.mem.findScalarPos(u8, text, 0, '`');i = if (close) |p| p + 1 else text.len;emitString(text, 0, i, true, sink);if (close == null) return .template;@@ -98,11 +98,11 @@ pub fn tokenize(text: []const u8, state: State, sink: anytype) State {if (ch == '/' and i + 1 < text.len and (text[i + 1] == '/' or text[i + 1] == '*')) {const start = i;if (text[i + 1] == '/') {- i = std.mem.indexOfScalarPos(u8, text, i + 2, '\n') orelse text.len;+ i = std.mem.findScalarPos(u8, text, i + 2, '\n') orelse text.len;sink.emit(start, i - start, .comment);continue;}- const close = std.mem.indexOfPos(u8, text, i + 2, "*/");+ const close = std.mem.findPos(u8, text, i + 2, "*/");i = if (close) |p| p + 2 else text.len;sink.emit(start, i - start, .comment);if (close == null) return .block_comment;diff --git a/src/agent/md_term.zig b/src/agent/md_term.zigindex e59534a81..eae16d2b9 100644--- a/src/agent/md_term.zig+++ b/src/agent/md_term.zig@@ -172,7 +172,7 @@ const CellIterator = struct {};fn cellIterator(row: []const u8) CellIterator {- const first_pipe = std.mem.indexOfScalar(u8, row, '|');+ const first_pipe = std.mem.findScalar(u8, row, '|');return .{ .row = row, .pos = if (first_pipe) |p| p + 1 else 0 };}@@ -232,7 +232,7 @@ fn renderFenceRule(w: *std.Io.Writer, opening: bool, delimiter: []const u8) !voivar fill: usize = rule_width - 1;if (opening) {const info = std.mem.trim(u8, std.mem.trimStart(u8, delimiter, " \t`"), " \t");- const lang = info[0 .. std.mem.indexOfAny(u8, info, " \t") orelse info.len];+ const lang = info[0 .. std.mem.findAny(u8, info, " \t") orelse info.len];if (lang.len > 0 and lang.len + 4 <= fill) {try w.writeAll("─ ");try w.writeAll(lang);@@ -308,7 +308,7 @@ pub const Stream = struct {pub fn feed(self: *Stream, w: *std.Io.Writer, data: []const u8) !void {var rest = data;- while (std.mem.indexOfScalar(u8, rest, '\n')) |nl| {+ while (std.mem.findScalar(u8, rest, '\n')) |nl| {const head = rest[0..nl];rest = rest[nl + 1 ..];if (self.raw) {@@ -534,7 +534,7 @@ fn renderInlineStyled(w: *std.Io.Writer, text: []const u8, active: ?*const Stylei += 2;continue;},- '`' => if (std.mem.indexOfPos(u8, text, i + 1, "`")) |end| {+ '`' => if (std.mem.findPos(u8, text, i + 1, "`")) |end| {try styled(w, text[i + 1 .. end], ansi.teal);try Style.applyOpt(active, w);i = end + 1;@@ -543,19 +543,19 @@ fn renderInlineStyled(w: *std.Io.Writer, text: []const u8, active: ?*const Style'*', '_' => |ch| {const double = [2]u8{ ch, ch };if (i + 1 < text.len and text[i + 1] == ch) {- if (std.mem.indexOfPos(u8, text, i + 2, &double)) |end| {+ if (std.mem.findPos(u8, text, i + 2, &double)) |end| {try span(w, text[i + 2 .. end], ansi.bold, active);i = end + 2;continue;}- } else if (std.mem.indexOfScalarPos(u8, text, i + 1, ch)) |end| {+ } else if (std.mem.findScalarPos(u8, text, i + 1, ch)) |end| {try span(w, text[i + 1 .. end], ansi.italic, active);i = end + 1;continue;}},'~' => if (i + 1 < text.len and text[i + 1] == '~') {- if (std.mem.indexOfPos(u8, text, i + 2, "~~")) |end| {+ if (std.mem.findPos(u8, text, i + 2, "~~")) |end| {try span(w, text[i + 2 .. end], ansi.strike, active);i = end + 2;continue;@@ -660,8 +660,8 @@ fn isHorizontalRule(line: []const u8) bool {/// Returns the index past the `)`, or null (nothing written) if unterminated.fn renderLinkAt(w: *std.Io.Writer, text: []const u8, open: usize, active: ?*const Style) std.Io.Writer.Error!?usize {- const mid = std.mem.indexOfPos(u8, text, open + 1, "](") orelse return null;- const close = std.mem.indexOfScalarPos(u8, text, mid + 2, ')') orelse return null;+ const mid = std.mem.findPos(u8, text, open + 1, "](") orelse return null;+ const close = std.mem.findScalarPos(u8, text, mid + 2, ')') orelse return null;try renderLink(w, text[open + 1 .. mid], text[mid + 2 .. close], active);return close + 1;}@@ -841,7 +841,7 @@ test "md_term: batch aligns tables beyond the stream table buffer" {const pipe = "\x1b[2m│\x1b[0m";try testing.expectEqual(0, std.mem.count(u8, out, "| a"));try testing.expectEqual(500, std.mem.count(u8, out, pipe ++ " " ++ repeat("a", 16) ++ " " ++ pipe));- try testing.expect(std.mem.indexOf(u8, out, "\x1b[2m├" ++ repeat("─", 18) ++ "┼" ++ repeat("─", 18) ++ "┤\x1b[0m\n") != null);+ try testing.expect(std.mem.find(u8, out, "\x1b[2m├" ++ repeat("─", 18) ++ "┼" ++ repeat("─", 18) ++ "┤\x1b[0m\n") != null);}test "md_term: stream falls back to raw rows past its table buffer" {diff --git a/src/agent/prompt_assist.zig b/src/agent/prompt_assist.zigindex 6b200b9b8..ea890915b 100644--- a/src/agent/prompt_assist.zig+++ b/src/agent/prompt_assist.zig@@ -214,7 +214,7 @@ fn analyzeBody(schema: *const Schema, body: []const u8, ends_ws: bool) BodyAnalyconst last = n - 1;for (tokens[0..n], 0..) |tok, i| {- if (std.mem.indexOfScalar(u8, tok, '=')) |eq| {+ if (std.mem.findScalar(u8, tok, '=')) |eq| {a.markUsed(tok[0..eq]);continue;}@@ -234,7 +234,7 @@ const help_arg_prefix = "/help ";fn parseHelpArgPrefix(input: []const u8) ?[]const u8 {if (!std.ascii.startsWithIgnoreCase(input, help_arg_prefix)) return null;const arg = std.mem.trimStart(u8, input[help_arg_prefix.len..], " ");- if (std.mem.indexOfScalar(u8, arg, ' ') != null) return null;+ if (std.mem.findScalar(u8, arg, ' ') != null) return null;return arg;}@@ -265,7 +265,7 @@ fn valueAt(schema: *const Schema, body: []const u8, ends_ws: bool) ?ValueAt {const active: []const u8 = if (ends_ws or n == 0) "" else last;const active_index: usize = if (ends_ws or n == 0) n else n - 1;- if (std.mem.indexOfScalar(u8, active, '=')) |eq| {+ if (std.mem.findScalar(u8, active, '=')) |eq| {const field = schema.findField(active[0..eq]) orelse return null;return .{ .field = field, .partial = active[eq + 1 ..], .kv = true };}@@ -331,7 +331,7 @@ fn addMetaValueCompletions(buf: *[completion_buf_len:0]u8,) void {// Past the first positional arg — don't offer value completions anymore.- if (std.mem.indexOfAny(u8, body, &std.ascii.whitespace) != null) return;+ if (std.mem.findAny(u8, body, &std.ascii.whitespace) != null) return;const prefix = input[0 .. input.len - body.len];if (meta.tag == .load or meta.tag == .save) {@@ -370,7 +370,7 @@ const PathMatchIterator = struct {const Match = struct { name: []const u8, is_dir: bool };fn init(body: []const u8) ?PathMatchIterator {- const slash = std.mem.lastIndexOfScalar(u8, body, '/');+ const slash = std.mem.findScalarLast(u8, body, '/');const dir_part = if (slash) |i| body[0 .. i + 1] else "";const open_path = if (dir_part.len == 0) "." else dir_part;const dir = std.Io.Dir.cwd().openDir(lp.io, open_path, .{ .iterate = true }) catch return null;@@ -426,7 +426,7 @@ fn addEnvVarCompletions(buf: *[completion_buf_len:0]u8,input: []const u8,) void {- const dollar = std.mem.lastIndexOfScalar(u8, input, '$') orelse return;+ const dollar = std.mem.findScalarLast(u8, input, '$') orelse return;const partial = input[dollar + 1 ..];for (partial) |ch| {if (!std.ascii.isAlphanumeric(ch) and ch != '_') return;@@ -453,7 +453,7 @@ fn completionCallback(cenv: ?*c.ic_completion_env_t, prefix: [*c]const u8) callc}if (input.len == 0) return;- const has_space = std.mem.indexOfScalar(u8, input, ' ') != null;+ const has_space = std.mem.findScalar(u8, input, ' ') != null;const inside_block = Schema.hasUnclosedTripleQuote(input);if (input[0] == '/') {@@ -515,7 +515,7 @@ fn hintsCallback(input_c: [*c]const u8, arg: ?*anyopaque) callconv(.c) [*c]constif (SlashCommand.findMeta(parts.name)) |meta| {return renderMetaHint(state, meta, parts.rest, ends_ws);}- if (std.mem.indexOfScalar(u8, input, ' ') == null) {+ if (std.mem.findScalar(u8, input, ' ') == null) {return ghostFirstMatch(&SlashCommand.all_names, parts.name, "");}return null;@@ -647,7 +647,7 @@ fn highlighterCallback(henv: ?*c.ic_highlight_env_t, input: [*c]const u8, arg: ?highlightJavaScript(henv, text);return;}- const cmd_start = std.mem.indexOfNonePos(u8, text, 0, &std.ascii.whitespace) orelse return;+ const cmd_start = std.mem.findNonePos(u8, text, 0, &std.ascii.whitespace) orelse return;var i = cmd_start;while (i < text.len and !std.ascii.isWhitespace(text[i])) i += 1;const cmd = text[cmd_start..i];@@ -739,7 +739,7 @@ fn highlightJavaScript(henv: ?*c.ic_highlight_env_t, text: []const u8) void {fn highlightSlashArgs(henv: ?*c.ic_highlight_env_t, text: []const u8, start: usize) void {var i = start;- while (std.mem.indexOfNonePos(u8, text, i, &std.ascii.whitespace)) |tok_start| {+ while (std.mem.findNonePos(u8, text, i, &std.ascii.whitespace)) |tok_start| {i = tok_start;if (text[i] == '\'' or text[i] == '"') {i = Schema.quotedSpanEnd(text, i);diff --git a/src/agent/save.zig b/src/agent/save.zigindex ccbf988a7..91bfe8b2d 100644--- a/src/agent/save.zig+++ b/src/agent/save.zig@@ -43,11 +43,11 @@ pub fn parseCommand(arena: std.mem.Allocator, rest: []const u8) !Command {var after: []const u8 = undefined;if (trimmed[0] == '\'' or trimmed[0] == '"') {const quote = trimmed[0];- const end = std.mem.indexOfScalarPos(u8, trimmed, 1, quote) orelse return error.UnterminatedQuote;+ const end = std.mem.findScalarPos(u8, trimmed, 1, quote) orelse return error.UnterminatedQuote;name = trimmed[1..end];after = trimmed[end + 1 ..];} else {- const tok_end = std.mem.indexOfAny(u8, trimmed, &std.ascii.whitespace) orelse trimmed.len;+ const tok_end = std.mem.findAny(u8, trimmed, &std.ascii.whitespace) orelse trimmed.len;name = trimmed[0..tok_end];after = trimmed[tok_end..];}@@ -118,9 +118,9 @@ pub fn writeContentFile(path: []const u8, content: []const u8, mode: Mode) !voidpub fn stripCodeFence(text: []const u8) []const u8 {const t = std.mem.trim(u8, text, &std.ascii.whitespace);if (!std.mem.startsWith(u8, t, "```")) return t;- const first_nl = std.mem.indexOfScalar(u8, t, '\n') orelse return t;+ const first_nl = std.mem.findScalar(u8, t, '\n') orelse return t;const body = t[first_nl + 1 ..];- const close = std.mem.lastIndexOf(u8, body, "```") orelse return std.mem.trim(u8, body, &std.ascii.whitespace);+ const close = std.mem.findLast(u8, body, "```") orelse return std.mem.trim(u8, body, &std.ascii.whitespace);return std.mem.trim(u8, body[0..close], &std.ascii.whitespace);}diff --git a/src/browser/Frame.zig b/src/browser/Frame.zigindex ea6073350..b5865cca9 100644--- a/src/browser/Frame.zig+++ b/src/browser/Frame.zig@@ -1001,7 +1001,7 @@ fn scheduleNavigationWithArena(originator: *Frame, arena: *lp.Arena, request_urlif (!opts.force andopts.kind != .reload andstd.mem.eql(u8, target.url, resolved_url) and- std.mem.indexOfScalar(u8, resolved_url, '#') != null)+ std.mem.findScalar(u8, resolved_url, '#') != null){arena.release();return;@@ -1216,7 +1216,7 @@ fn loadEventsAborted(self: *const Frame) bool {pub fn cancelQueuedNavigation(self: *Frame) void {const qn = self._queued_navigation orelse return;const queued = self.page.queued_navigation;- if (std.mem.indexOfScalar(*Frame, queued.items, self)) |idx| {+ if (std.mem.findScalar(*Frame, queued.items, self)) |idx| {_ = queued.swapRemove(idx);}qn.arena.release();@@ -1652,8 +1652,8 @@ fn dispositionFilename(disposition: HttpClient.Header) ?[]const u8 {// Prefer the extended filename*= form when present, per RFC 6266.if (disposition.param("filename*")) |ext| {// charset'lang'value — take everything after the second quote.- if (std.mem.indexOfScalar(u8, ext, '\'')) |first| {- if (std.mem.indexOfScalarPos(u8, ext, first + 1, '\'')) |second| {+ if (std.mem.findScalar(u8, ext, '\'')) |first| {+ if (std.mem.findScalarPos(u8, ext, first + 1, '\'')) |second| {return sanitizeFilename(ext[second + 1 ..]);}}@@ -1670,7 +1670,7 @@ fn dispositionFilename(disposition: HttpClient.Header) ?[]const u8 {// regardless of the host platform.fn sanitizeFilename(name: []const u8) ?[]const u8 {var out = std.fs.path.basename(name);- if (std.mem.lastIndexOfScalar(u8, out, '\\')) |i| {+ if (std.mem.findScalarLast(u8, out, '\\')) |i| {out = out[i + 1 ..];}if (out.len == 0 or std.mem.eql(u8, out, ".") or std.mem.eql(u8, out, "..")) {@@ -1746,7 +1746,7 @@ fn frameDataCallback(transfer: *HttpClient.Transfer, data: []const u8) !void {self._pending_content_type = null;if (mime.content_type != .text_html) {if (transfer.contentType()) |ct| {- const end = std.mem.indexOfScalarPos(u8, ct, 0, ';') orelse ct.len;+ const end = std.mem.findScalarPos(u8, ct, 0, ';') orelse ct.len;const essence = std.mem.trim(u8, ct[0..end], " \t");if (essence.len > 0) {self._pending_content_type = try std.ascii.allocLowerString(self.arena, essence);@@ -1787,7 +1787,7 @@ fn frameDataCallback(transfer: *HttpClient.Transfer, data: []const u8) !void {// the parser turns a literal "★" in the body into a star.var v = data;while (v.len > 0) {- const index = std.mem.indexOfAnyPos(u8, v, 0, &.{ '<', '>', '&' }) orelse {+ const index = std.mem.findAnyPos(u8, v, 0, &.{ '<', '>', '&' }) orelse {return buf.appendSlice(self.arena, v);};try buf.appendSlice(self.arena, v[0..index]);@@ -2131,7 +2131,7 @@ pub fn iframeAddedCallback(self: *Frame, iframe: *IFrame) !void {// extra defensive..maybe navigate added a new frame, and the index it// was added at was removed. Or maybe this frame was removed somehow// (which I don't think is possible)- if (std.mem.indexOfScalar(*Frame, self.child_frames.items, new_frame)) |idx| {+ if (std.mem.findScalar(*Frame, self.child_frames.items, new_frame)) |idx| {_ = self.child_frames.swapRemove(idx);}log.debug(.frame, "iframe navigate failure", .{ .url = url, .err = err });diff --git a/src/browser/ImportMap.zig b/src/browser/ImportMap.zigindex 66e62cc6f..07fc43afb 100644--- a/src/browser/ImportMap.zig+++ b/src/browser/ImportMap.zig@@ -348,7 +348,7 @@ fn resolveImportsMatch(}fn isSpecialUrl(url: []const u8) bool {- const colon = std.mem.indexOfScalarPos(u8, url, 0, ':') orelse return false;+ const colon = std.mem.findScalarPos(u8, url, 0, ':') orelse return false;const scheme = url[0..colon];inline for (.{ "https", "http", "ws", "wss", "file", "ftp" }) |s| {if (std.ascii.eqlIgnoreCase(scheme, s)) {diff --git a/src/browser/Mime.zig b/src/browser/Mime.zigindex 2300b803f..772b49b02 100644--- a/src/browser/Mime.zig+++ b/src/browser/Mime.zig@@ -115,7 +115,7 @@ pub const ContentTypeIterator = struct {// Skip whitespace.const trimmed = std.mem.trimStart(u8, content_type, &.{ ' ', '\t' });// Find semicolon delimiter; or just use the end position.- const end = std.mem.indexOfScalar(u8, trimmed, ';') orelse trimmed.len;+ const end = std.mem.findScalar(u8, trimmed, ';') orelse trimmed.len;const essence = std.mem.trimEnd(u8, trimmed[0..end], &.{ ' ', '\t' });// Rest of the parameters.@@ -134,12 +134,12 @@ pub const ContentTypeIterator = struct {while (self.rest.len > 0) {// `rest` always sits at the `;` that introduced this parameter.var param = self.rest[1..];- const end = std.mem.indexOfScalar(u8, param, ';') orelse param.len;+ const end = std.mem.findScalar(u8, param, ';') orelse param.len;self.rest = param[end..];param = std.mem.trim(u8, param[0..end], " \t");// Parameters without `=` are malformed; skip them.- const eq = std.mem.indexOfScalar(u8, param, '=') orelse continue;+ const eq = std.mem.findScalar(u8, param, '=') orelse continue;const key = std.mem.trimEnd(u8, param[0..eq], " \t");if (key.len == 0) {continue;@@ -247,7 +247,7 @@ pub fn prescanCharset(html: []const u8) ?[]const u8 {var pos: usize = 0;while (pos < data.len) {// Find next '<'- pos = std.mem.indexOfScalarPos(u8, data, pos, '<') orelse return null;+ pos = std.mem.findScalarPos(u8, data, pos, '<') orelse return null;pos += 1;if (pos >= data.len) return null;@@ -269,7 +269,7 @@ pub fn prescanCharset(html: []const u8) ?[]const u8 {}// Scan attributes within this meta tag- const tag_end = std.mem.indexOfScalarPos(u8, data, pos, '>') orelse return null;+ const tag_end = std.mem.findScalarPos(u8, data, pos, '>') orelse return null;const attrs = data[pos..tag_end];// Look for charset= attribute directly@@ -466,7 +466,7 @@ pub fn isText(mime: *const Mime) bool {// we expect value to be lowercasefn parseContentType(value: []const u8) !struct { ContentType, usize } {- const end = std.mem.indexOfScalarPos(u8, value, 0, ';') orelse value.len;+ const end = std.mem.findScalarPos(u8, value, 0, ';') orelse value.len;const type_name = trimRight(value[0..end]);const attribute_start = end + 1;@@ -510,7 +510,7 @@ fn parseContentType(value: []const u8) !struct { ContentType, usize } {return .{ ct, attribute_start };}- const separator = std.mem.indexOfScalarPos(u8, type_name, 0, '/') orelse return error.Invalid;+ const separator = std.mem.findScalarPos(u8, type_name, 0, '/') orelse return error.Invalid;const main_type = value[0..separator];const sub_type = trimRight(value[separator + 1 .. end]);@@ -559,14 +559,14 @@ pub fn serialize(arena: Allocator, input: []const u8) ![]const u8 {}// type "/" subtype- const slash = std.mem.indexOfScalarPos(u8, trimmed, 0, '/') orelse return "";+ const slash = std.mem.findScalarPos(u8, trimmed, 0, '/') orelse return "";const type_name = trimmed[0..slash];if (isHttpToken(type_name) == false) {return "";}var rest = trimmed[slash + 1 ..];- const subtype_end = std.mem.indexOfScalar(u8, rest, ';') orelse rest.len;+ const subtype_end = std.mem.findScalar(u8, rest, ';') orelse rest.len;const subtype = std.mem.trimEnd(u8, rest[0..subtype_end], &HTTP_WHITESPACE);if (isHttpToken(subtype) == false) {return "";diff --git a/src/browser/SelectorPath.zig b/src/browser/SelectorPath.zigindex a8b8c75bd..1de655102 100644--- a/src/browser/SelectorPath.zig+++ b/src/browser/SelectorPath.zig@@ -199,7 +199,7 @@ fn nthOfType(el: *Element) ?usize {}fn isPlainAttrValue(value: []const u8) bool {- return std.mem.indexOfAny(u8, value, "\"\\\n") == null;+ return std.mem.findAny(u8, value, "\"\\\n") == null;}/// Mirrors how click/fill resolve a selector: the same `Selector.querySelector`diff --git a/src/browser/Session.zig b/src/browser/Session.zigindex 31d0c2732..071b0ee0b 100644--- a/src/browser/Session.zig+++ b/src/browser/Session.zig@@ -333,7 +333,7 @@ fn retire(self: *Session, page: *Page) void {}fn removePageFromList(self: *Session, page: *Page) void {- if (std.mem.indexOfScalar(*Page, self.pages.items, page)) |i| {+ if (std.mem.findScalar(*Page, self.pages.items, page)) |i| {_ = self.pages.swapRemove(i);}}diff --git a/src/browser/StyleManager.zig b/src/browser/StyleManager.zigindex 834ba50b8..32d2fe897 100644--- a/src/browser/StyleManager.zig+++ b/src/browser/StyleManager.zig@@ -191,7 +191,7 @@ fn applyLayerAtRule(self: *StyleManager, build_arena: Allocator, text: []const u// invalidates the whole statement. Validate everything before// registering anything.var names = text["@layer".len..];- if (std.mem.indexOfScalar(u8, names, ';')) |semi| {+ if (std.mem.findScalar(u8, names, ';')) |semi| {names = names[0..semi];}@@ -265,7 +265,7 @@ fn atRuleBlock(text: []const u8, keyword: []const u8) ?struct { prelude: []const// Search only past the opening brace — the matching `}` lives there, and// any returned position is naturally `> open` (since `rest[open] == '{'`).- const close = open + (std.mem.lastIndexOfScalar(u8, rest[open..], '}') orelse return null);+ const close = open + (std.mem.findScalarLast(u8, rest[open..], '}') orelse return null);return .{ .prelude = rest[0..open], .body = rest[open + 1 .. close] };}@@ -275,7 +275,7 @@ fn indexOfOpenBraceSkippingComments(s: []const u8) ?usize {var i: usize = 0;while (i < s.len) {if (i + 1 < s.len and s[i] == '/' and s[i + 1] == '*') {- const close = std.mem.indexOf(u8, s[i + 2 ..], "*/") orelse return null;+ const close = std.mem.find(u8, s[i + 2 ..], "*/") orelse return null;i = i + 2 + close + 2;continue;}diff --git a/src/browser/URL.zig b/src/browser/URL.zigindex 72f85d1bb..a3efc9db6 100644--- a/src/browser/URL.zig+++ b/src/browser/URL.zig@@ -154,7 +154,7 @@ pub fn isCompleteHTTPUrl(url: []const u8) bool {}// Check if there's a scheme (protocol) ending with ://- const colon_pos = std.mem.indexOfScalar(u8, url, ':') orelse return false;+ const colon_pos = std.mem.findScalar(u8, url, ':') orelse return false;// Check if it's followed by //if (colon_pos + 2 >= url.len or url[colon_pos + 1] != '/' or url[colon_pos + 2] != '/') {@@ -183,30 +183,30 @@ pub fn isCompleteHTTPUrl(url: []const u8) bool {pub fn getUsername(raw: [:0]const u8) []const u8 {const user_info = getUserInfo(raw) orelse return "";- const pos = std.mem.indexOfScalarPos(u8, user_info, 0, ':') orelse return user_info;+ const pos = std.mem.findScalarPos(u8, user_info, 0, ':') orelse return user_info;return user_info[0..pos];}pub fn getPassword(raw: [:0]const u8) []const u8 {const user_info = getUserInfo(raw) orelse return "";- const pos = std.mem.indexOfScalarPos(u8, user_info, 0, ':') orelse return "";+ const pos = std.mem.findScalarPos(u8, user_info, 0, ':') orelse return "";return user_info[pos + 1 ..];}pub fn getPathname(raw: [:0]const u8) []const u8 {- const protocol_end = std.mem.indexOf(u8, raw, "://");+ const protocol_end = std.mem.find(u8, raw, "://");// Handle scheme:path URLs like about:blank (no "://")if (protocol_end == null) {- const colon_pos = std.mem.indexOfScalar(u8, raw, ':') orelse return "";+ const colon_pos = std.mem.findScalar(u8, raw, ':') orelse return "";const path = raw[colon_pos + 1 ..];- const query_or_hash = std.mem.indexOfAny(u8, path, "?#") orelse path.len;+ const query_or_hash = std.mem.findAny(u8, path, "?#") orelse path.len;return path[0..query_or_hash];}- const path_start = std.mem.indexOfScalarPos(u8, raw, protocol_end.? + 3, '/') orelse raw.len;+ const path_start = std.mem.findScalarPos(u8, raw, protocol_end.? + 3, '/') orelse raw.len;- const query_or_hash_start = std.mem.indexOfAnyPos(u8, raw, path_start, "?#") orelse raw.len;+ const query_or_hash_start = std.mem.findAnyPos(u8, raw, path_start, "?#") orelse raw.len;if (path_start >= query_or_hash_start) {return "/";@@ -216,7 +216,7 @@ pub fn getPathname(raw: [:0]const u8) []const u8 {}pub fn getProtocol(raw: []const u8) []const u8 {- const pos = std.mem.indexOfScalarPos(u8, raw, 0, ':') orelse return "";+ const pos = std.mem.findScalarPos(u8, raw, 0, ':') orelse return "";return raw[0 .. pos + 1];}@@ -275,7 +275,7 @@ pub fn getPort(raw: []const u8) []const u8 {fn findPortSeparator(host: []const u8) ?usize {if (host.len > 0 and host[0] == '[') {// IPv6: find closing bracket, port separator must be after it- const bracket_end = std.mem.indexOfScalar(u8, host, ']') orelse return null;+ const bracket_end = std.mem.findScalar(u8, host, ']') orelse return null;if (bracket_end + 1 < host.len and host[bracket_end + 1] == ':') {return bracket_end + 1;}@@ -283,7 +283,7 @@ fn findPortSeparator(host: []const u8) ?usize {}// Regular host: find last colon and verify it's followed by digits- const pos = std.mem.lastIndexOfScalar(u8, host, ':') orelse return null;+ const pos = std.mem.findScalarLast(u8, host, ':') orelse return null;if (pos + 1 >= host.len) return null;for (host[pos + 1 ..]) |c| {@@ -293,10 +293,10 @@ fn findPortSeparator(host: []const u8) ?usize {}pub fn getSearch(raw: [:0]const u8) []const u8 {- const pos = std.mem.indexOfScalarPos(u8, raw, 0, '?') orelse return "";+ const pos = std.mem.findScalarPos(u8, raw, 0, '?') orelse return "";const query_part = raw[pos..];- if (std.mem.indexOfScalarPos(u8, query_part, 0, '#')) |fragment_start| {+ if (std.mem.findScalarPos(u8, query_part, 0, '#')) |fragment_start| {return query_part[0..fragment_start];}@@ -304,12 +304,12 @@ pub fn getSearch(raw: [:0]const u8) []const u8 {}pub fn getHash(raw: [:0]const u8) []const u8 {- const start = std.mem.indexOfScalarPos(u8, raw, 0, '#') orelse return "";+ const start = std.mem.findScalarPos(u8, raw, 0, '#') orelse return "";return raw[start..];}pub fn getOrigin(allocator: Allocator, raw: [:0]const u8) !?[]const u8 {- const scheme_end = std.mem.indexOf(u8, raw, "://") orelse return null;+ const scheme_end = std.mem.find(u8, raw, "://") orelse return null;// Only HTTP and HTTPS schemes have originsconst protocol = raw[0 .. scheme_end + 1];@@ -323,7 +323,7 @@ pub fn getOrigin(allocator: Allocator, raw: [:0]const u8) !?[]const u8 {// Check for port in the host:port sectionconst host_part = auth.getHost(raw);- if (std.mem.lastIndexOfScalar(u8, host_part, ':')) |colon_pos_in_host| {+ if (std.mem.findScalarLast(u8, host_part, ':')) |colon_pos_in_host| {const port = host_part[colon_pos_in_host + 1 ..];// Validate it's actually a port (all digits)@@ -382,7 +382,7 @@ fn getUserInfo(raw: [:0]const u8) ?[]const u8 {if (!auth.has_user_info) return null;// User info is from authority_start to host_start - 1 (excluding the @)- const scheme_end = std.mem.indexOf(u8, raw, "://").?;+ const scheme_end = std.mem.find(u8, raw, "://").?;const authority_start = scheme_end + 3;return raw[authority_start .. auth.host_start - 1];}@@ -395,8 +395,8 @@ pub fn getHost(raw: []const u8) []const u8 {// Returns true if these two URLs point to the same document.pub fn eqlDocument(first: [:0]const u8, second: [:0]const u8) bool {// First '#' signifies the start of the fragment.- const first_hash_index = std.mem.indexOfScalar(u8, first, '#') orelse first.len;- const second_hash_index = std.mem.indexOfScalar(u8, second, '#') orelse second.len;+ const first_hash_index = std.mem.findScalar(u8, first, '#') orelse first.len;+ const second_hash_index = std.mem.findScalar(u8, second, '#') orelse second.len;return std.mem.eql(u8, first[0..first_hash_index], second[0..second_hash_index]);}@@ -440,7 +440,7 @@ pub fn setHost(current: [:0]const u8, value: []const u8, allocator: Allocator) !const hash = getHash(current);// Check if the new value includes a port- const colon_pos = std.mem.lastIndexOfScalar(u8, value, ':');+ const colon_pos = std.mem.findScalarLast(u8, value, ':');const clean_host = if (colon_pos) |pos| blk: {const port_str = value[pos + 1 ..];// Remove default ports@@ -618,7 +618,7 @@ pub fn concatQueryString(arena: Allocator, url: []const u8, query_string: []constry buf.ensureTotalCapacityPrecise(arena, url.len + 2 + query_string.len);buf.appendSliceAssumeCapacity(url);- if (std.mem.indexOfScalar(u8, url, '?')) |index| {+ if (std.mem.findScalar(u8, url, '?')) |index| {const last_index = url.len - 1;if (index != last_index and url[last_index] != '&') {buf.appendAssumeCapacity('&');@@ -641,7 +641,7 @@ pub fn getRobotsUrl(arena: Allocator, url: [:0]const u8) ![:0]const u8 {}pub fn unescape(arena: Allocator, input: []const u8) ![]const u8 {- if (std.mem.indexOfScalar(u8, input, '%') == null) {+ if (std.mem.findScalar(u8, input, '%') == null) {return input;}@@ -668,7 +668,7 @@ pub fn unescape(arena: Allocator, input: []const u8) ![]const u8 {}pub fn stripFragment(url: []const u8) []const u8 {- return url[0 .. std.mem.indexOfScalar(u8, url, '#') orelse url.len];+ return url[0 .. std.mem.findScalar(u8, url, '#') orelse url.len];}const AuthorityInfo = struct {@@ -686,19 +686,19 @@ const AuthorityInfo = struct {// SECURITY: Only looks for @ within the authority portion (before /?#)// to prevent path-based @ injection attacks.fn parseAuthority(raw: []const u8) ?AuthorityInfo {- const scheme_end = std.mem.indexOf(u8, raw, "://") orelse return null;+ const scheme_end = std.mem.find(u8, raw, "://") orelse return null;const authority_start = scheme_end + 3;// Find end of authority FIRST (start of path/query/fragment,// a NUL/CR/LF/TAB, or end of string).- const authority_end = if (std.mem.indexOfAny(u8, raw[authority_start..], "/?#\x00\r\n\t")) |end|+ const authority_end = if (std.mem.findAny(u8, raw[authority_start..], "/?#\x00\r\n\t")) |end|authority_start + endelseraw.len;// Only look for @ within the authority portion, not in path/query/fragmentconst authority_portion = raw[authority_start..authority_end];- if (std.mem.indexOf(u8, authority_portion, "@")) |pos| {+ if (std.mem.find(u8, authority_portion, "@")) |pos| {return .{.host_start = authority_start + pos + 1,.host_end = authority_end,diff --git a/src/browser/clutter.zig b/src/browser/clutter.zigindex d77280ed1..33469b6c5 100644--- a/src/browser/clutter.zig+++ b/src/browser/clutter.zig@@ -850,7 +850,7 @@ const negative = [_][]const u8{ "-ad-", "hidden", "banner", "combx", "comment",fn containsAny(haystack: []const u8, needles: []const []const u8) bool {for (needles) |needle| {- if (std.mem.indexOf(u8, haystack, needle) != null) return true;+ if (std.mem.find(u8, haystack, needle) != null) return true;}return false;}@@ -866,7 +866,7 @@ fn isShareElement(names: []const u8) bool {fn hasWord(haystack: []const u8, word: []const u8) bool {var start: usize = 0;- while (std.mem.indexOfPos(u8, haystack, start, word)) |i| : (start = i + 1) {+ while (std.mem.findPos(u8, haystack, start, word)) |i| : (start = i + 1) {const before = i == 0 or !std.ascii.isAlphanumeric(haystack[i - 1]);const end = i + word.len;const after = end == haystack.len or !std.ascii.isAlphanumeric(haystack[end]);@@ -898,28 +898,28 @@ test "clutter: keeps the article, drops the teaser list and share bar" {"<div class=\"article\"><h1>Sourdough</h1><div class=\"share\"><a href=\"/s\">Share on X</a> <a href=\"/f\">Share on Facebook</a></div>" ++"<p>" ++ prose ++ "</p><p>" ++ prose ++ "</p><p>" ++ prose ++ "</p></div>";const out = try extract(html);- try testing.expectEqual(true, std.mem.indexOf(u8, out, "wild lactobacillaceae") != null);- try testing.expectEqual(true, std.mem.indexOf(u8, out, "# Sourdough") != null);- try testing.expectEqual(null, std.mem.indexOf(u8, out, "Trending now"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "Share on"));+ try testing.expectEqual(true, std.mem.find(u8, out, "wild lactobacillaceae") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "# Sourdough") != null);+ try testing.expectEqual(null, std.mem.find(u8, out, "Trending now"));+ try testing.expectEqual(null, std.mem.find(u8, out, "Share on"));}test "clutter: too little text falls back" {const out = try extract("<div><p>A short note.</p></div><div><a href=\"/1\">one</a> <a href=\"/2\">two</a></div>");- try testing.expectEqual(true, std.mem.indexOf(u8, out, "A short note.") != null);- try testing.expectEqual(true, std.mem.indexOf(u8, out, "two") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "A short note.") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "two") != null);}test "clutter: retry ladder rescues content in an unlikely class" {const out = try extract("<div class=\"sidebar\"><p>" ++ prose ++ "</p><p>" ++ prose ++ "</p><p>" ++ prose ++ "</p></div><div><a href=\"/x\">elsewhere</a></div>");- try testing.expectEqual(true, std.mem.indexOf(u8, out, "wild lactobacillaceae") != null);- try testing.expectEqual(null, std.mem.indexOf(u8, out, "elsewhere"));+ try testing.expectEqual(true, std.mem.find(u8, out, "wild lactobacillaceae") != null);+ try testing.expectEqual(null, std.mem.find(u8, out, "elsewhere"));}test "clutter: qualifying sibling paragraphs come along" {const out = try extract("<div id=\"wrap\"><div class=\"body\"><p>" ++ prose ++ "</p><p>" ++ prose ++ "</p></div><p>" ++ prose ++ "</p><div class=\"nav\"><a href=\"/a\">a</a> <a href=\"/b\">b</a> <a href=\"/c\">c</a></div></div>");try testing.expectEqual(3, std.mem.count(u8, out, "wild lactobacillaceae"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "[a]"));+ try testing.expectEqual(null, std.mem.find(u8, out, "[a]"));}test "clutter: anchors without href are not link text" {@@ -928,7 +928,7 @@ test "clutter: anchors without href are not link text" {const tagged = "<div class=\"quote\"><span>I have not failed. I've just found ten thousand ways that won't work.</span><span>by Thomas A. Edison</span>" ++"<div class=\"tags\">Tags: <a class=\"tag\">edison</a> <a class=\"tag\">failure</a> <a class=\"tag\">inspirational</a> <a class=\"tag\">paraphrased</a></div></div>";const out = try extract("<div class=\"quotes\">" ++ quote ++ quote ++ tagged ++ quote ++ "</div>");- try testing.expectEqual(true, std.mem.indexOf(u8, out, "ten thousand ways") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "ten thousand ways") != null);}test "clutter: the prune set lives in the caller's allocator" {@@ -948,7 +948,7 @@ test "clutter: the prune set lives in the caller's allocator" {var aw: std.Io.Writer.Allocating = .init(testing.allocator);defer aw.deinit();try markdown.dump(.{ .root = div.asNode() }, .{}, &aw.writer, frame);- try testing.expectEqual(true, std.mem.indexOf(u8, aw.written(), "Share") != null);+ try testing.expectEqual(true, std.mem.find(u8, aw.written(), "Share") != null);// Too little text: no set, no clutter.const second = try RenderTree.resolve(arena.allocator(), div.lastElementChild().?.asNode(), .{ .clutter = true }, frame);@@ -972,12 +972,12 @@ test "clutter: the HTML dump leaves out what the markdown dump does" {try dump.render(state, .{}, &aw.writer, frame);const out = aw.written();- try testing.expectEqual(true, std.mem.indexOf(u8, out, "wild lactobacillaceae") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "wild lactobacillaceae") != null);// Neither node renders, so RenderTree never yields either one; the set// still has to hold them, because the HTML dump walks the DOM itself.- try testing.expectEqual(null, std.mem.indexOf(u8, out, "__DATA__"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "Accept our cookies"));- try testing.expectEqual(null, std.mem.indexOf(u8, out, "Trending now"));+ try testing.expectEqual(null, std.mem.find(u8, out, "__DATA__"));+ try testing.expectEqual(null, std.mem.find(u8, out, "Accept our cookies"));+ try testing.expectEqual(null, std.mem.find(u8, out, "Trending now"));}fn extract(html: []const u8) ![]const u8 {diff --git a/src/browser/css/MediaQuery.zig b/src/browser/css/MediaQuery.zigindex 3481a44d0..a860ef192 100644--- a/src/browser/css/MediaQuery.zig+++ b/src/browser/css/MediaQuery.zig@@ -73,7 +73,7 @@ fn hasUnterminatedComment(s: []const u8) bool {var i: usize = 0;while (i + 1 < s.len) {if (s[i] == '/' and s[i + 1] == '*') {- const close = std.mem.indexOfPos(u8, s, i + 2, "*/") orelse return true;+ const close = std.mem.findPos(u8, s, i + 2, "*/") orelse return true;i = close + 2;continue;}@@ -91,7 +91,7 @@ fn skipWsAndComments(s: []const u8, start: usize) usize {if (std.ascii.isWhitespace(s[i])) {i += 1;} else if (i + 1 < s.len and s[i] == '/' and s[i + 1] == '*') {- const close = std.mem.indexOfPos(u8, s, i + 2, "*/") orelse return s.len;+ const close = std.mem.findPos(u8, s, i + 2, "*/") orelse return s.len;i = close + 2;} else break;}@@ -107,7 +107,7 @@ fn trimWsAndComments(s: []const u8) []const u8 {if (std.ascii.isWhitespace(s[start])) {start += 1;} else if (start + 1 < end and s[start] == '/' and s[start + 1] == '*') {- const close = std.mem.indexOfPos(u8, s, start + 2, "*/") orelse return s[start..end];+ const close = std.mem.findPos(u8, s, start + 2, "*/") orelse return s[start..end];start = close + 2;} else break;}@@ -115,7 +115,7 @@ fn trimWsAndComments(s: []const u8) []const u8 {if (std.ascii.isWhitespace(s[end - 1])) {end -= 1;} else if (end >= start + 2 and s[end - 1] == '/' and s[end - 2] == '*') {- const open_rel = std.mem.lastIndexOf(u8, s[start .. end - 2], "/*") orelse return s[start..end];+ const open_rel = std.mem.findLast(u8, s[start .. end - 2], "/*") orelse return s[start..end];end = start + open_rel;} else break;}@@ -128,7 +128,7 @@ fn indexOfScalarSkippingComments(s: []const u8, needle: u8) ?usize {var i: usize = 0;while (i < s.len) {if (i + 1 < s.len and s[i] == '/' and s[i + 1] == '*') {- const close = std.mem.indexOfPos(u8, s, i + 2, "*/") orelse return null;+ const close = std.mem.findPos(u8, s, i + 2, "*/") orelse return null;i = close + 2;continue;}@@ -143,7 +143,7 @@ fn nextTopLevelComma(s: []const u8) usize {var i: usize = 0;while (i < s.len) {if (i + 1 < s.len and s[i] == '/' and s[i + 1] == '*') {- const close = std.mem.indexOfPos(u8, s, i + 2, "*/") orelse return s.len;+ const close = std.mem.findPos(u8, s, i + 2, "*/") orelse return s.len;i = close + 2;continue;}@@ -242,7 +242,7 @@ fn findClosingParen(s: []const u8, open: usize) ?usize {var i = open + 1;while (i < s.len) {if (i + 1 < s.len and s[i] == '/' and s[i + 1] == '*') {- const close = std.mem.indexOfPos(u8, s, i + 2, "*/") orelse return null;+ const close = std.mem.findPos(u8, s, i + 2, "*/") orelse return null;i = close + 2;continue;}diff --git a/src/browser/data_url.zig b/src/browser/data_url.zigindex 49496aa90..4214134a9 100644--- a/src/browser/data_url.zig+++ b/src/browser/data_url.zig@@ -35,7 +35,7 @@ pub fn parse(arena: Allocator, url: []const u8) !Parsed {const after = url["data:".len..];- const comma = std.mem.indexOfScalarPos(u8, after, 0, ',') orelse return error.InvalidDataUrl;+ const comma = std.mem.findScalarPos(u8, after, 0, ',') orelse return error.InvalidDataUrl;var meta = std.mem.trim(u8, after[0..comma], &std.ascii.whitespace);const encoded_body = after[comma + 1 ..];diff --git a/src/browser/dump.zig b/src/browser/dump.zigindex 30eca503e..fdda23671 100644--- a/src/browser/dump.zig+++ b/src/browser/dump.zig@@ -632,14 +632,14 @@ fn shouldEscapeText(node_: ?*Node) bool {}fn writeEscapedText(text: []const u8, writer: *std.Io.Writer) !void {// Fast path: if no special characters, write directly- const first_special = std.mem.indexOfAnyPos(u8, text, 0, &.{ '&', '<', '>', 194 }) orelse {+ const first_special = std.mem.findAnyPos(u8, text, 0, &.{ '&', '<', '>', 194 }) orelse {return writer.writeAll(text);};try writer.writeAll(text[0..first_special]);var remaining = try writeEscapedByte(text, first_special, writer);- while (std.mem.indexOfAnyPos(u8, remaining, 0, &.{ '&', '<', '>', 194 })) |offset| {+ while (std.mem.findAnyPos(u8, remaining, 0, &.{ '&', '<', '>', 194 })) |offset| {try writer.writeAll(remaining[0..offset]);remaining = try writeEscapedByte(remaining, offset, writer);}@@ -924,7 +924,7 @@ test "dump: with_frames and with_base inject a <base> in every document" {// Each content document gets its own LimitedWriter; the cut must still happen// once, with a single marker and no end tags after it.test "dump: max_bytes cut inside a nested content document" {- const cut = comptime std.mem.indexOf(u8, frames_dump, "<b>deep").? + 4;+ const cut = comptime std.mem.find(u8, frames_dump, "<b>deep").? + 4;try expectPageDump("dump_frames.html",.{ .with_frames = true, .max_bytes = cut },diff --git a/src/browser/frame/framing.zig b/src/browser/frame/framing.zigindex eb9486cd7..9b9ccb5f0 100644--- a/src/browser/frame/framing.zig+++ b/src/browser/frame/framing.zig@@ -69,7 +69,7 @@ fn hasFrameAncestors(csp: []const u8) bool {continue;}}- if (pos == csp.len or std.mem.indexOfScalar(u8, HTTP_WHITESPACE ++ ";,", csp[pos]) != null) {+ if (pos == csp.len or std.mem.findScalar(u8, HTTP_WHITESPACE ++ ";,", csp[pos]) != null) {return true;}}diff --git a/src/browser/frame/node_factory.zig b/src/browser/frame/node_factory.zigindex 09a29f84a..1c0b5f2d1 100644--- a/src/browser/frame/node_factory.zig+++ b/src/browser/frame/node_factory.zig@@ -826,7 +826,7 @@ pub fn createElementNS(document: *const Node.Document, namespace: Element.Namespconst tag_name = try String.init(frame.arena, name, .{});// Check if this is a custom element (must have hyphen for HTML namespace)- const has_hyphen = std.mem.indexOfScalar(u8, name, '-') != null;+ const has_hyphen = std.mem.findScalar(u8, name, '-') != null;if (has_hyphen and namespace == .html) {// A document without a browsing context has no registry: its// elements stay undefined until inserted into a document that@@ -1207,7 +1207,7 @@ pub fn createComment(document: *const Node.Document, text: []const u8) !*Node {pub fn createCDATASection(document: *const Node.Document, data: []const u8) !*Node {// Validate that the data doesn't contain "]]>"- if (std.mem.indexOf(u8, data, "]]>") != null) {+ if (std.mem.find(u8, data, "]]>") != null) {return error.InvalidCharacterError;}@@ -1221,10 +1221,10 @@ pub fn createCDATASection(document: *const Node.Document, data: []const u8) !*Nopub fn createProcessingInstruction(document: *const Node.Document, target: []const u8, data: []const u8) !*Node {// Validate neither target nor data contain "?>"- if (std.mem.indexOf(u8, target, "?>") != null) {+ if (std.mem.find(u8, target, "?>") != null) {return error.InvalidCharacterError;}- if (std.mem.indexOf(u8, data, "?>") != null) {+ if (std.mem.find(u8, data, "?>") != null) {return error.InvalidCharacterError;}diff --git a/src/browser/js/Env.zig b/src/browser/js/Env.zigindex a929e476d..7a10714bc 100644--- a/src/browser/js/Env.zig+++ b/src/browser/js/Env.zig@@ -965,8 +965,8 @@ test "Env: stall report names the running frame and script stack" {try testing.expectEqual(frame.url, state.url[0..state.url_len]);try testing.expectEqual(true, state.page_url_matches);const stack = state.stack[0..state.stack_len];- const inner = std.mem.indexOf(u8, stack, "stallInner (https://example.com/stall.js:3:") orelse return error.MissingInnerFrame;- const outer = std.mem.indexOf(u8, stack, "stallOuter (https://example.com/stall.js:2:") orelse return error.MissingOuterFrame;+ const inner = std.mem.find(u8, stack, "stallInner (https://example.com/stall.js:3:") orelse return error.MissingInnerFrame;+ const outer = std.mem.find(u8, stack, "stallOuter (https://example.com/stall.js:2:") orelse return error.MissingOuterFrame;try testing.expect(inner < outer);}diff --git a/src/browser/js/WasmStreaming.zig b/src/browser/js/WasmStreaming.zigindex 94cb495fd..7d53a3139 100644--- a/src/browser/js/WasmStreaming.zig+++ b/src/browser/js/WasmStreaming.zig@@ -144,7 +144,7 @@ pub fn abort(self: *WasmStreaming, exception: ?*const v8.Value) void {fn release(self: *WasmStreaming) void {v8.std__shared_ptr__v8__WasmStreaming__reset(&self.handle);const streams = &self.ctx.wasm_streams;- if (std.mem.indexOfScalar(*WasmStreaming, streams.items, self)) |i| {+ if (std.mem.findScalar(*WasmStreaming, streams.items, self)) |i| {_ = streams.swapRemove(i);}}diff --git a/src/browser/pdf.zig b/src/browser/pdf.zigindex e0ea9321b..8371bd317 100644--- a/src/browser/pdf.zig+++ b/src/browser/pdf.zig@@ -75,8 +75,8 @@ pub fn parsePageRanges(arena: Allocator, text: []const u8) error{ InvalidPageRanconst part = std.mem.trim(u8, raw, &std.ascii.whitespace);if (part.len == 0) continue;var range: PageRange = undefined;- if (std.mem.indexOfScalar(u8, part, '-')) |dash| {- if (std.mem.indexOfScalarPos(u8, part, dash + 1, '-') != null) return error.InvalidPageRangeSyntax;+ if (std.mem.findScalar(u8, part, '-')) |dash| {+ if (std.mem.findScalarPos(u8, part, dash + 1, '-') != null) return error.InvalidPageRangeSyntax;const a = std.mem.trim(u8, part[0..dash], &std.ascii.whitespace);const b = std.mem.trim(u8, part[dash + 1 ..], &std.ascii.whitespace);range.from = if (a.len == 0) 1 else parsePageNumber(a) orelse return error.InvalidPageRangeSyntax;@@ -189,7 +189,7 @@ pub const Prepared = struct {if (measure_only) {return page_count;}- if (std.mem.indexOfScalar(bool, doc.selected, true) == null) {+ if (std.mem.findScalar(bool, doc.selected, true) == null) {return error.NoPagesSelected;}try doc.draw();@@ -1044,17 +1044,17 @@ test "browser.pdf: structure, pagination and links" {try testing.expectEqual("%%EOF\n", out[out.len - 6 ..]);try testing.expectEqual(1, std.mem.count(u8, out, "/Type /Page "));// Letter in points, and the three faces the text used, each embedded once.- try testing.expectEqual(true, std.mem.indexOf(u8, out, "/MediaBox [0 0 612.000 792.000]") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "/MediaBox [0 0 612.000 792.000]") != null);try testing.expectEqual(3, std.mem.count(u8, out, "/Subtype /Type0"));try testing.expectEqual(3, std.mem.count(u8, out, "/FontFile2"));- try testing.expectEqual(true, std.mem.indexOf(u8, out, "/Encoding /Identity-H") != null);+ try testing.expectEqual(true, std.mem.find(u8, out, "/Encoding /Identity-H") != null);// Well under the 2MB of bundled fonts: they were subset.try testing.expectEqual(true, out.len < 120_000);// The one link is a URI annotation on the page, resolved to absolute.try testing.expectEqual(1, std.mem.count(u8, out, "/Subtype /Link"));try testing.expectEqual(1, std.mem.count(u8, out, "/Annots ["));const uri = "/URI <" ++ std.fmt.bytesToHex("http://localhost/x", .upper) ++ ">";- try testing.expectEqual(true, std.mem.indexOf(u8, out, uri) != null);+ try testing.expectEqual(true, std.mem.find(u8, out, uri) != null);// 200 paragraphs don't fit one Letter page; a range then picks pages.const long = try doc.createElement("div", null, frame);@@ -1085,7 +1085,7 @@ test "browser.pdf: structure, pagination and links" {aw.clearRetainingCapacity();try print(testing.arena_allocator, .{ .root = long.asNode() }, .{ .paper_width = 1056, .paper_height = 816, .margin_top = 300, .margin_bottom = 300 }, &aw.writer, frame);- try testing.expectEqual(true, std.mem.indexOf(u8, aw.written(), "/MediaBox [0 0 792.000 612.000]") != null);+ try testing.expectEqual(true, std.mem.find(u8, aw.written(), "/MediaBox [0 0 792.000 612.000]") != null);try testing.expectEqual(true, std.mem.count(u8, aw.written(), "/Type /Page ") > pages);}diff --git a/src/browser/structured_data.zig b/src/browser/structured_data.zigindex b89763261..44909466f 100644--- a/src/browser/structured_data.zig+++ b/src/browser/structured_data.zig@@ -303,7 +303,7 @@ const LinkHeaderIterator = struct {}const target_start = self.i + 1;- const gt = std.mem.indexOfScalarPos(u8, v, target_start, '>') orelse {+ const gt = std.mem.findScalarPos(u8, v, target_start, '>') orelse {self.i = v.len;return null;};@@ -348,7 +348,7 @@ fn extractRel(params: []const u8) ?[]const u8 {var it = std.mem.splitScalar(u8, params, ';');while (it.next()) |raw_param| {const param = std.mem.trim(u8, raw_param, &std.ascii.whitespace);- const eq = std.mem.indexOfScalarPos(u8, param, 0, '=') orelse continue;+ const eq = std.mem.findScalarPos(u8, param, 0, '=') orelse continue;const name = std.mem.trim(u8, param[0..eq], &std.ascii.whitespace);if (std.ascii.eqlIgnoreCase(name, "rel") == false) {continue;@@ -515,7 +515,7 @@ test "structured_data: json-ld" {defer testing.test_session.closeAllPages();try testing.expectEqual(1, data.json_ld.len);- try testing.expect(std.mem.indexOf(u8, data.json_ld[0], "Article") != null);+ try testing.expect(std.mem.find(u8, data.json_ld[0], "Article") != null);}test "structured_data: multiple json-ld" {diff --git a/src/browser/tools.zig b/src/browser/tools.zigindex e90924957..e29438806 100644--- a/src/browser/tools.zig+++ b/src/browser/tools.zig@@ -2282,11 +2282,11 @@ const RegexLiteral = struct {/// written as `/foo/` still matches itself, the search being unanchored.fn regexLiteral(text: []const u8) ?RegexLiteral {if (text.len == 0 or text[0] != '/') return null;- const close = std.mem.lastIndexOfScalar(u8, text, '/') orelse return null;+ const close = std.mem.findScalarLast(u8, text, '/') orelse return null;if (close < 2) return null;const flags = text[close + 1 ..];for (flags) |flag| {- if (std.mem.indexOfScalar(u8, "dgimsuvy", flag) == null) return null;+ if (std.mem.findScalar(u8, "dgimsuvy", flag) == null) return null;}return .{ .body = text[1..close], .flags = flags };}@@ -2338,7 +2338,7 @@ pub fn lpEnvNames(arena: std.mem.Allocator) error{OutOfMemory}![]const []const uvar ptr = std.c.environ;while (ptr[0]) |entry| : (ptr += 1) {const line = std.mem.span(entry);- const eq_idx = std.mem.indexOfScalar(u8, line, '=') orelse continue;+ const eq_idx = std.mem.findScalar(u8, line, '=') orelse continue;const name = line[0..eq_idx];if (!std.mem.startsWith(u8, name, "LP_")) continue;try env_names.append(arena, try arena.dupe(u8, name));@@ -2630,7 +2630,7 @@ fn substituteStringArgs(arena: std.mem.Allocator, tool: Tool, args: ?std.json.Vaconst needsSub = struct {fn f(is_fill_: bool, key: []const u8, val: std.json.Value) bool {if (is_fill_ and std.mem.eql(u8, key, "value")) return false;- return val == .string and std.mem.indexOf(u8, val.string, "$LP_") != null;+ return val == .string and std.mem.find(u8, val.string, "$LP_") != null;}}.f;@@ -2659,13 +2659,13 @@ pub fn substituteEnvVars(arena: std.mem.Allocator, input: []const u8) error{OutO// Pages routinely contain `$5.99`-style content where `$` is incidental.// Lowercase `$lp_…` falls through here too — `getenv` is// case-sensitive on Linux, so it would never resolve anyway.- const first_lp = std.mem.indexOf(u8, input, "$LP_") orelse return input;+ const first_lp = std.mem.find(u8, input, "$LP_") orelse return input;var result: std.ArrayList(u8) = .empty;try result.ensureTotalCapacity(arena, input.len);var i: usize = first_lp;var last_copy: usize = 0;- while (std.mem.indexOfScalarPos(u8, input, i, '$')) |dollar| {+ while (std.mem.findScalarPos(u8, input, i, '$')) |dollar| {const var_start = dollar + 1;var var_end = var_start;while (var_end < input.len and (std.ascii.isAlphanumeric(input[var_end]) or input[var_end] == '_')) {@@ -2716,7 +2716,7 @@ pub fn reverseSubstituteEnvVars(arena: std.mem.Allocator, input: []const u8) errvar current: []const u8 = input;var changed = false;for (pairs.items) |p| {- if (std.mem.indexOf(u8, current, p.value) == null) continue;+ if (std.mem.find(u8, current, p.value) == null) continue;const placeholder = try arena.print("${s}", .{p.name});current = try std.mem.replaceOwned(u8, arena, current, p.value, placeholder);changed = true;@@ -2751,12 +2751,12 @@ test "tree and nodeDetails read the node's own frame" {const aa = testing.arena_allocator;const tree_args = try std.json.parseFromSliceLeaky(std.json.Value, aa, try aa.print("{{\"backendNodeId\":{d}}}", .{html_id}), .{});const tree = try call(aa, page.session, ®istry, "tree", tree_args, .{});- try std.testing.expect(std.mem.indexOf(u8, tree.text, "child-label") != null);- try std.testing.expect(std.mem.indexOf(u8, tree.text, "parent-") == null);+ try std.testing.expect(std.mem.find(u8, tree.text, "child-label") != null);+ try std.testing.expect(std.mem.find(u8, tree.text, "parent-") == null);const details_args = try std.json.parseFromSliceLeaky(std.json.Value, aa, try aa.print("{{\"backendNodeId\":{d}}}", .{input_id}), .{});const details = try call(aa, page.session, ®istry, "nodeDetails", details_args, .{});- try std.testing.expect(std.mem.indexOf(u8, details.text, "child-label") != null);+ try std.testing.expect(std.mem.find(u8, details.text, "child-label") != null);}test "goto: a navigation stuck waiting for a connection is an error" {@@ -2920,7 +2920,7 @@ test "execGetEnv hides non-LP_ values even when set" {const arguments: std.json.Value = .{ .object = obj };const r = try execGetEnv(aa, arguments);- try std.testing.expect(std.mem.indexOf(u8, r, var_value) == null);+ try std.testing.expect(std.mem.find(u8, r, var_value) == null);try std.testing.expectEqualStrings("Environment variable '" ++ var_name ++ "' is not set",r,@@ -2935,9 +2935,9 @@ test "formatLpEnvNames renders names without values" {const env_names = [_][]const u8{ "LP_BAR", "LP_FOO" };const r = try formatLpEnvNames(aa, &env_names);- try std.testing.expect(std.mem.indexOf(u8, r, "LP_FOO") != null);- try std.testing.expect(std.mem.indexOf(u8, r, "LP_BAR") != null);- try std.testing.expect(std.mem.indexOf(u8, r, "secret") == null);+ try std.testing.expect(std.mem.find(u8, r, "LP_FOO") != null);+ try std.testing.expect(std.mem.find(u8, r, "LP_BAR") != null);+ try std.testing.expect(std.mem.find(u8, r, "secret") == null);}test "formatLpEnvNames reports empty when no names" {@@ -2964,11 +2964,11 @@ test "tavily results render as markdown" {};const md = try renderResults(aa, try collectTavily(aa, resp));- try std.testing.expect(std.mem.indexOf(u8, md, "**Answer:** Paris") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "1. **Paris - Wikipedia**") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "https://en.wikipedia.org/wiki/Paris") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "Paris is the capital of France.") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "2. **France**") != null);+ try std.testing.expect(std.mem.find(u8, md, "**Answer:** Paris") != null);+ try std.testing.expect(std.mem.find(u8, md, "1. **Paris - Wikipedia**") != null);+ try std.testing.expect(std.mem.find(u8, md, "https://en.wikipedia.org/wiki/Paris") != null);+ try std.testing.expect(std.mem.find(u8, md, "Paris is the capital of France.") != null);+ try std.testing.expect(std.mem.find(u8, md, "2. **France**") != null);}test "tavily: no results render as a notice" {@@ -2994,10 +2994,10 @@ test "brave results render as markdown" {};const md = try renderResults(aa, try collectBrave(aa, resp));- try std.testing.expect(std.mem.indexOf(u8, md, "1. **Paris - Wikipedia**") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "https://en.wikipedia.org/wiki/Paris") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "Paris is the capital of France.") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "2. **France**") != null);+ try std.testing.expect(std.mem.find(u8, md, "1. **Paris - Wikipedia**") != null);+ try std.testing.expect(std.mem.find(u8, md, "https://en.wikipedia.org/wiki/Paris") != null);+ try std.testing.expect(std.mem.find(u8, md, "Paris is the capital of France.") != null);+ try std.testing.expect(std.mem.find(u8, md, "2. **France**") != null);}test "brave: no results render as a notice" {@@ -3024,10 +3024,10 @@ test "keenable results render the snippet as the body" {};const md = try renderResults(aa, try collectKeenable(aa, resp));- try std.testing.expect(std.mem.indexOf(u8, md, "1. **Zig (programming language)**") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "Zig is a system programming language.") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "2. **Zig guide**") != null);- try std.testing.expect(std.mem.indexOf(u8, md, "Compile-time execution.") != null);+ try std.testing.expect(std.mem.find(u8, md, "1. **Zig (programming language)**") != null);+ try std.testing.expect(std.mem.find(u8, md, "Zig is a system programming language.") != null);+ try std.testing.expect(std.mem.find(u8, md, "2. **Zig guide**") != null);+ try std.testing.expect(std.mem.find(u8, md, "Compile-time execution.") != null);}test "writeResultItem uses the URL as title when the title is empty" {@@ -3074,10 +3074,10 @@ test "searchFailed: a rate limit says so, a bare failure stays short" {.message = "Public API hourly limit reached.\nWait 2 minutes to continue.",});try std.testing.expect(limited.is_error);- try std.testing.expect(std.mem.indexOf(u8, limited.text, "(HTTP 429)") != null);- try std.testing.expect(std.mem.indexOf(u8, limited.text, "Public API hourly limit reached.") != null);- try std.testing.expect(std.mem.indexOf(u8, limited.text, "rate-limited right now") != null);- try std.testing.expect(std.mem.indexOf(u8, limited.text, "\n") == null);+ try std.testing.expect(std.mem.find(u8, limited.text, "(HTTP 429)") != null);+ try std.testing.expect(std.mem.find(u8, limited.text, "Public API hourly limit reached.") != null);+ try std.testing.expect(std.mem.find(u8, limited.text, "rate-limited right now") != null);+ try std.testing.expect(std.mem.find(u8, limited.text, "\n") == null);const bare = try searchFailed(aa, "web", error.ConnectionRefused, .{});try std.testing.expectEqualStrings("web search failed: ConnectionRefused", bare.text);diff --git a/src/browser/webapi/CustomElementRegistry.zig b/src/browser/webapi/CustomElementRegistry.zigindex cfa534545..14850d2cc 100644--- a/src/browser/webapi/CustomElementRegistry.zig+++ b/src/browser/webapi/CustomElementRegistry.zig@@ -287,7 +287,7 @@ fn validateName(name: []const u8) !void {return error.SyntaxError;}- if (std.mem.indexOf(u8, name, "-") == null) {+ if (std.mem.find(u8, name, "-") == null) {return error.SyntaxError;}diff --git a/src/browser/webapi/Document.zig b/src/browser/webapi/Document.zigindex 93e4c2885..8d96047c6 100644--- a/src/browser/webapi/Document.zig+++ b/src/browser/webapi/Document.zig@@ -290,7 +290,7 @@ fn setDomain(self: *Document, value: []const u8) !void {// only ever match another explicitly set domain.// The scheme is preserved (http and https must never collide) and the// port is dropped, per spec.- const scheme_end = (std.mem.indexOf(u8, origin, "://") orelse return error.SecurityError) + 3;+ const scheme_end = (std.mem.find(u8, origin, "://") orelse return error.SecurityError) + 3;const key = try std.mem.concat(arena, u8, &.{ "!", origin[0..scheme_end], requested });try doc_frame.js.setOrigin(key);}@@ -365,7 +365,7 @@ fn isRelaxableTo(host: []const u8, requested: []const u8) bool {}// it can't be a bare TLD, "com"- if (std.mem.indexOfScalar(u8, requested, '.') == null) {+ if (std.mem.findScalar(u8, requested, '.') == null) {return false;}@@ -1267,7 +1267,7 @@ pub fn open(self: *Document, call_frame: *Frame) !*Document {// gone for good, as in Chrome.frame.cancelQueuedNavigation();- if (std.mem.indexOfScalar(*Document, frame._script_created_parser_docs.items, self) == null) {+ if (std.mem.findScalar(*Document, frame._script_created_parser_docs.items, self) == null) {// have the page track this document (if it isn't already)// so that, on shutdown, it can close the parser if needed.try frame._script_created_parser_docs.append(frame.arena, self);@@ -1564,7 +1564,7 @@ pub fn validateAndExtract(namespace_: ?[]const u8, qualified_name: []const u8, cvar prefix: ?[]const u8 = null;var local_name = qualified_name;- if (std.mem.indexOfScalar(u8, qualified_name, ':')) |colon| {+ if (std.mem.findScalar(u8, qualified_name, ':')) |colon| {prefix = qualified_name[0..colon];local_name = qualified_name[colon + 1 ..];if (!isValidNamespacePrefix(prefix.?)) {diff --git a/src/browser/webapi/Element.zig b/src/browser/webapi/Element.zigindex 038add03a..f461c8b5d 100644--- a/src/browser/webapi/Element.zig+++ b/src/browser/webapi/Element.zig@@ -517,7 +517,7 @@ pub fn lookupPrefixForElement(self: *Element, namespace: []const u8, frame: *Frafn _prefix(self: *const Element) ?[]const u8 {const name = self.getTagNameLower();- if (std.mem.indexOfPos(u8, name, 0, ":")) |pos| {+ if (std.mem.findPos(u8, name, 0, ":")) |pos| {return name[0..pos];}return null;@@ -525,7 +525,7 @@ fn _prefix(self: *const Element) ?[]const u8 {pub fn getLocalName(self: *Element) []const u8 {const name = self.getTagNameLower();- if (std.mem.indexOfPos(u8, name, 0, ":")) |pos| {+ if (std.mem.findPos(u8, name, 0, ":")) |pos| {return name[pos + 1 ..];}@@ -845,12 +845,12 @@ pub fn setAttributeNS(value: String,frame: *Frame,) !void {- const local_start = if (std.mem.indexOfScalarPos(u8, qualified_name, 0, ':')) |idx| blk: {+ const local_start = if (std.mem.findScalarPos(u8, qualified_name, 0, ':')) |idx| blk: {if (idx == 0 or idx == qualified_name.len - 1) {// cannot be at the start or end of the qnamereturn error.InvalidCharacterError;}- if (std.mem.indexOfScalarPos(u8, qualified_name, idx + 1, ':') != null) {+ if (std.mem.findScalarPos(u8, qualified_name, idx + 1, ':') != null) {// and can only have onereturn error.InvalidCharacterError;}diff --git a/src/browser/webapi/Location.zig b/src/browser/webapi/Location.zigindex 5e08c6ecd..e9443cdad 100644--- a/src/browser/webapi/Location.zig+++ b/src/browser/webapi/Location.zig@@ -102,7 +102,7 @@ fn setSearch(_: *const Location, search: []const u8, frame: *Frame) !void {fn setHash(_: *const Location, hash: []const u8, frame: *Frame) !void {const old_url = frame.url;- const base_end = std.mem.indexOfScalar(u8, old_url, '#') orelse old_url.len;+ const base_end = std.mem.findScalar(u8, old_url, '#') orelse old_url.len;// Includes the leading '#'; empty when the URL has no fragment.const old_fragment = old_url[base_end..];diff --git a/src/browser/webapi/Navigator.zig b/src/browser/webapi/Navigator.zigindex 720b5a7dd..e9b8195c8 100644--- a/src/browser/webapi/Navigator.zig+++ b/src/browser/webapi/Navigator.zig@@ -244,7 +244,7 @@ fn validateProtocolHandlerScheme(scheme: []const u8) !void {}fn validateProtocolHandlerURL(url: [:0]const u8, frame: *const Frame) !void {- if (std.mem.indexOf(u8, url, "%s") == null) {+ if (std.mem.find(u8, url, "%s") == null) {return error.SyntaxError;}if (frame.isSameOrigin(url) == false) {diff --git a/src/browser/webapi/Performance.zig b/src/browser/webapi/Performance.zigindex a4bc5d509..bda83ecea 100644--- a/src/browser/webapi/Performance.zig+++ b/src/browser/webapi/Performance.zig@@ -345,7 +345,7 @@ fn gated(self: *const Performance, allow: bool, micros: u64) f64 {// https://mimesniff.spec.whatwg.org/#minimize-a-supported-mime-typefn minimizeMimeType(header: []const u8) []const u8 {var buf: [255]u8 = undefined;- const raw = std.mem.trim(u8, header[0 .. std.mem.indexOfScalar(u8, header, ';') orelse header.len], " \t");+ const raw = std.mem.trim(u8, header[0 .. std.mem.findScalar(u8, header, ';') orelse header.len], " \t");if (raw.len > buf.len) {return "";}@@ -430,7 +430,7 @@ fn contentEncoding(header: []const u8) []const u8 {if (header.len == 0) {return "";}- if (std.mem.indexOfScalar(u8, header, ',') != null) {+ if (std.mem.findScalar(u8, header, ',') != null) {return "multiple";}var buf: [8]u8 = undefined;diff --git a/src/browser/webapi/ServiceWorkerContainer.zig b/src/browser/webapi/ServiceWorkerContainer.zigindex d60a4279d..09155b9fb 100644--- a/src/browser/webapi/ServiceWorkerContainer.zig+++ b/src/browser/webapi/ServiceWorkerContainer.zig@@ -128,7 +128,7 @@ pub fn register(self: *ServiceWorkerContainer, url: []const u8, options: ?Registconst scope_url = blk: {const raw = opts.scope orelse blk2: {// A registration's default scope is the script's own directory.- const end = std.mem.lastIndexOfScalar(u8, script_url, '/') orelse break :blk2 script_url;+ const end = std.mem.findScalarLast(u8, script_url, '/') orelse break :blk2 script_url;break :blk2 script_url[0 .. end + 1];};diff --git a/src/browser/webapi/URLPattern.zig b/src/browser/webapi/URLPattern.zigindex ecac70368..7c2fc1b11 100644--- a/src/browser/webapi/URLPattern.zig+++ b/src/browser/webapi/URLPattern.zig@@ -794,7 +794,7 @@ fn processInit(arena: Allocator, in: Init, comptime typ: InitType) Error!Init {if (base) |b| {if (!urlHasOpaquePath(b) and !isAbsolutePathname(pathname, typ)) {const base_path = try processBaseUrlString(arena, urlPath(b), typ);- if (std.mem.lastIndexOfScalar(u8, base_path, '/')) |slash| {+ if (std.mem.findScalarLast(u8, base_path, '/')) |slash| {pathname = try std.mem.concat(arena, u8, &.{ base_path[0 .. slash + 1], pathname });}}@@ -1898,7 +1898,7 @@ const Component = struct {const raw = groups.get(part.name) orelse return error.TypeError;const value = try self.encoding(env.arena, raw);if (self.options.delimiter) |delimiter| {- if (std.mem.indexOfScalar(u8, value, delimiter) != null) {+ if (std.mem.findScalar(u8, value, delimiter) != null) {return error.TypeError;}}diff --git a/src/browser/webapi/Window.zig b/src/browser/webapi/Window.zigindex 6205956b5..6c8cff532 100644--- a/src/browser/webapi/Window.zig+++ b/src/browser/webapi/Window.zig@@ -1167,7 +1167,7 @@ fn hasFeatureToken(features: []const u8, token: []const u8) bool {var it = std.mem.tokenizeAny(u8, features, " \t\r\n,");while (it.next()) |raw| {// Trim a trailing =value if present — we only need the key.- const key = if (std.mem.indexOfScalarPos(u8, raw, 0, '=')) |eq| raw[0..eq] else raw;+ const key = if (std.mem.findScalarPos(u8, raw, 0, '=')) |eq| raw[0..eq] else raw;if (std.ascii.eqlIgnoreCase(key, token)) return true;}return false;diff --git a/src/browser/webapi/cache/Store.zig b/src/browser/webapi/cache/Store.zigindex 64d519f9d..4c3adfd6a 100644--- a/src/browser/webapi/cache/Store.zig+++ b/src/browser/webapi/cache/Store.zig@@ -178,7 +178,7 @@ pub const Bucket = struct {};fn withoutSearch(url: []const u8) []const u8 {- return url[0 .. std.mem.indexOfAny(u8, url, "?#") orelse url.len];+ return url[0 .. std.mem.findAny(u8, url, "?#") orelse url.len];}// A stored request/response pair. Only the request's url is kept: entries arediff --git a/src/browser/webapi/canvas/context2d.zig b/src/browser/webapi/canvas/context2d.zigindex 68212fb0a..7080f694d 100644--- a/src/browser/webapi/canvas/context2d.zig+++ b/src/browser/webapi/canvas/context2d.zig@@ -156,7 +156,7 @@ fn parseFontSize(font: []const u8) ?f64 {var it = std.mem.tokenizeAny(u8, font, " \t\n\r");while (it.next()) |raw| {// "16px/1.5" carries a line-height.- const token = raw[0 .. std.mem.indexOfScalar(u8, raw, '/') orelse raw.len];+ const token = raw[0 .. std.mem.findScalar(u8, raw, '/') orelse raw.len];const units = [_]struct { suffix: []const u8, px: f64 }{.{ .suffix = "px", .px = 1 },.{ .suffix = "pt", .px = 4.0 / 3.0 },diff --git a/src/browser/webapi/collections/DOMTokenList.zig b/src/browser/webapi/collections/DOMTokenList.zigindex 49514219d..8b90e9a48 100644--- a/src/browser/webapi/collections/DOMTokenList.zig+++ b/src/browser/webapi/collections/DOMTokenList.zig@@ -160,10 +160,10 @@ pub fn replace(self: *DOMTokenList, old_token: []const u8, new_token: []const u8if (old_token.len == 0 or new_token.len == 0) {return error.SyntaxError;}- if (std.mem.indexOfAny(u8, old_token, WHITESPACE) != null) {+ if (std.mem.findAny(u8, old_token, WHITESPACE) != null) {return error.InvalidCharacterError;}- if (std.mem.indexOfAny(u8, new_token, WHITESPACE) != null) {+ if (std.mem.findAny(u8, new_token, WHITESPACE) != null) {return error.InvalidCharacterError;}@@ -276,7 +276,7 @@ fn validateToken(token: []const u8) !void {if (token.len == 0) {return error.SyntaxError;}- if (std.mem.indexOfAny(u8, token, &std.ascii.whitespace) != null) {+ if (std.mem.findAny(u8, token, &std.ascii.whitespace) != null) {return error.InvalidCharacterError;}}diff --git a/src/browser/webapi/css/CSSStyleDeclaration.zig b/src/browser/webapi/css/CSSStyleDeclaration.zigindex 911171ee8..b1c11170f 100644--- a/src/browser/webapi/css/CSSStyleDeclaration.zig+++ b/src/browser/webapi/css/CSSStyleDeclaration.zig@@ -492,13 +492,13 @@ fn normalizePropertyValue(arena: Allocator, property_name: []const u8, raw_value}// Canonicalize anchor-size() function: anchor name (dashed ident) comes before size keyword- if (std.mem.indexOf(u8, value, "anchor-size(")) |idx| {+ if (std.mem.find(u8, value, "anchor-size(")) |idx| {return canonicalizeAnchorSize(arena, value, idx);}// Canonicalize anchor() function: anchor name (dashed ident) comes before position keyword// Note: indexOf finds first occurrence, so we check it's not part of "anchor-size("- if (std.mem.indexOf(u8, value, "anchor(")) |idx| {+ if (std.mem.find(u8, value, "anchor(")) |idx| {if (idx == 0 or value[idx - 1] != '-') {return canonicalizeAnchor(arena, value, idx);}@@ -777,14 +777,14 @@ fn canonicalizeAnchor(arena: Allocator, value: []const u8, start_index: usize) !// Check if a value is "X X" (duplicate) and return just "X"fn collapseDuplicateValue(value: []const u8) ?[]const u8 {- const space_idx = std.mem.indexOfScalar(u8, value, ' ') orelse return null;+ const space_idx = std.mem.findScalar(u8, value, ' ') orelse return null;if (space_idx == 0 or space_idx >= value.len - 1) return null;const first = value[0..space_idx];const rest = std.mem.trimStart(u8, value[space_idx + 1 ..], " ");// Check if there's only one more value (no additional spaces)- if (std.mem.indexOfScalar(u8, rest, ' ') != null) return null;+ if (std.mem.findScalar(u8, rest, ' ') != null) return null;if (std.mem.eql(u8, first, rest)) {return first;diff --git a/src/browser/webapi/css/CSSStyleProperties.zig b/src/browser/webapi/css/CSSStyleProperties.zigindex 3ae24327f..cf0f6a400 100644--- a/src/browser/webapi/css/CSSStyleProperties.zig+++ b/src/browser/webapi/css/CSSStyleProperties.zig@@ -62,7 +62,7 @@ fn getNamed(self: *CSSStyleProperties, name: []const u8, frame: *Frame) ![]const// Only apply vendor prefix filtering for camelCase access (no dashes in input)// Bracket notation with dash-case (e.g., div.style['-moz-user-select']) should return the actual value- const is_camelcase_access = std.mem.indexOfScalar(u8, name, '-') == null;+ const is_camelcase_access = std.mem.findScalar(u8, name, '-') == null;if (is_camelcase_access and std.mem.startsWith(u8, dash_case, "-")) {// We only support -webkit-, other vendor prefixes return undefined for camelCase accessconst is_webkit = std.mem.startsWith(u8, dash_case, "-webkit-");@@ -334,7 +334,7 @@ fn camelCaseToDashCase(name: []const u8, buf: []u8) []const u8 {}// If already contains dashes, just return lowercased- if (std.mem.indexOfScalar(u8, name, '-')) |_| {+ if (std.mem.findScalar(u8, name, '-')) |_| {return lower_name;}diff --git a/src/browser/webapi/element/Attribute.zig b/src/browser/webapi/element/Attribute.zigindex 52721c4fe..70dae1e51 100644--- a/src/browser/webapi/element/Attribute.zig+++ b/src/browser/webapi/element/Attribute.zig@@ -531,7 +531,7 @@ pub fn validateAttributeName(name: String) !void {return error.InvalidCharacterError;}- if (std.mem.indexOfAny(u8, name_str, invalid_name_chars) != null) {+ if (std.mem.findAny(u8, name_str, invalid_name_chars) != null) {return error.InvalidCharacterError;}}@@ -714,7 +714,7 @@ fn formatAttribute(name: []const u8, value: []const u8, writer: *std.Io.Writer)}try writer.writeByte('"');- const offset = std.mem.indexOfAny(u8, value, "`' &\"<>=") orelse {+ const offset = std.mem.findAny(u8, value, "`' &\"<>=") orelse {try writer.writeAll(value);return writer.writeByte('"');};@@ -770,7 +770,7 @@ fn writeEscapedAttributeValue(value: []const u8, first_offset: usize, writer: *s});var remaining = value[first_offset + 1 ..];- while (std.mem.indexOfAny(u8, remaining, "&\"<>")) |offset| {+ while (std.mem.findAny(u8, remaining, "&\"<>")) |offset| {try writer.writeAll(remaining[0..offset]);try writer.writeAll(switch (remaining[offset]) {'&' => "&",diff --git a/src/browser/webapi/element/Html.zig b/src/browser/webapi/element/Html.zigindex a1715b608..197640f46 100644--- a/src/browser/webapi/element/Html.zig+++ b/src/browser/webapi/element/Html.zig@@ -1811,7 +1811,7 @@ fn renderedTextFragment(document: *const Node.Document, value: []const u8, framevar rest = value;while (true) {- const text_end = std.mem.indexOfAny(u8, rest, "\r\n") orelse rest.len;+ const text_end = std.mem.findAny(u8, rest, "\r\n") orelse rest.len;if (text_end > 0) {try nodes.append(arena, .{ .text = rest[0..text_end] });}diff --git a/src/browser/webapi/element/html/Input.zig b/src/browser/webapi/element/html/Input.zigindex 8c55eef80..eae07df58 100644--- a/src/browser/webapi/element/html/Input.zig+++ b/src/browser/webapi/element/html/Input.zig@@ -552,12 +552,12 @@ fn sameFormOwner(self_form: ?*Form, other: *Input, frame: *Frame) bool {/// the WHATWG "valid e-mail address" production loosely — sufficient for most/// constraint-validation tests; HTML browsers themselves are permissive here.fn isValidEmail(value: []const u8) bool {- const at = std.mem.indexOfScalar(u8, value, '@') orelse return false;+ const at = std.mem.findScalar(u8, value, '@') orelse return false;if (at == 0 or at == value.len - 1) return false;const local = value[0..at];const host = value[at + 1 ..];for (local) |c| if (!isEmailLocalChar(c)) return false;- if (std.mem.indexOfScalar(u8, host, '.') == null) return false;+ if (std.mem.findScalar(u8, host, '.') == null) return false;for (host) |c| if (!isEmailHostChar(c)) return false;if (host[0] == '.' or host[host.len - 1] == '.') return false;return true;@@ -578,7 +578,7 @@ fn isEmailHostChar(c: u8) bool {/// Absolute URL check per the WHATWG URL parser: must include a scheme followed/// by "://" and a non-empty authority. Relative URLs are typeMismatches per spec.fn isValidAbsoluteURL(value: []const u8) bool {- const scheme_end = std.mem.indexOfScalar(u8, value, ':') orelse return false;+ const scheme_end = std.mem.findScalar(u8, value, ':') orelse return false;if (scheme_end == 0) return false;if (!std.ascii.isAlphabetic(value[0])) return false;for (value[1..scheme_end]) |c| {@@ -756,7 +756,7 @@ fn sanitizeValue(self: *Input, comptime dupe: bool, value: []const u8, frame: *Fswitch (self._input_type) {.text, .search, .tel, .password, .url, .email => {const sanitized = blk: {- const first = std.mem.indexOfAny(u8, value, "\r\n") orelse {+ const first = std.mem.findAny(u8, value, "\r\n") orelse {break :blk if (comptime dupe) try frame.dupeString(value) else value;};@@ -953,7 +953,7 @@ fn valueToNumber(typ: Type, value: []const u8) ?f64 {return timeToMs(value);},.@"datetime-local" => {- const sep = std.mem.indexOfAny(u8, value, "T ") orelse return null;+ const sep = std.mem.findAny(u8, value, "T ") orelse return null;const date = value[0..sep];const time = value[sep + 1 ..];if (!isValidDate(date) or !isValidTime(time)) return null;diff --git a/src/browser/webapi/element/html/Media.zig b/src/browser/webapi/element/html/Media.zigindex 8f95667fc..31acaad81 100644--- a/src/browser/webapi/element/html/Media.zig+++ b/src/browser/webapi/element/html/Media.zig@@ -118,7 +118,7 @@ pub fn as(self: *Media, comptime T: type) *T {}fn canPlayType(_: *const Media, mime_type: []const u8, frame: *Frame) []const u8 {- const pos = std.mem.indexOfScalar(u8, mime_type, ';') orelse mime_type.len;+ const pos = std.mem.findScalar(u8, mime_type, ';') orelse mime_type.len;const base_type = std.mem.trim(u8, mime_type[0..pos], &std.ascii.whitespace);if (base_type.len > frame.buf.len) {diff --git a/src/browser/webapi/element/html/Meta.zig b/src/browser/webapi/element/html/Meta.zigindex f0961ca37..923a2f0e3 100644--- a/src/browser/webapi/element/html/Meta.zig+++ b/src/browser/webapi/element/html/Meta.zig@@ -124,7 +124,7 @@ fn immediateRefreshTarget(content: []const u8) ?[]const u8 {// The delay ends at the first separator. Without one, there's no URL.const separators = std.ascii.whitespace ++ [_]u8{ ';', ',' };- const separator = std.mem.indexOfAny(u8, trimmed, &separators) orelse return null;+ const separator = std.mem.findAny(u8, trimmed, &separators) orelse return null;const seconds = std.fmt.parseFloat(f64, trimmed[0..separator]) catch return null;if (seconds != 0) {// For now, we skip any meta refresh where the delay isn't 0. It isn't@@ -151,7 +151,7 @@ fn immediateRefreshTarget(content: []const u8) ?[]const u8 {if (rest.len > 0 and (rest[0] == '"' or rest[0] == '\'')) {const quote = rest[0];const quoted = rest[1..];- rest = quoted[0 .. std.mem.indexOfScalar(u8, quoted, quote) orelse quoted.len];+ rest = quoted[0 .. std.mem.findScalar(u8, quoted, quote) orelse quoted.len];}const target = std.mem.trim(u8, rest, &std.ascii.whitespace);diff --git a/src/browser/webapi/element/html/Source.zig b/src/browser/webapi/element/html/Source.zigindex c3d5a4ba5..97debd527 100644--- a/src/browser/webapi/element/html/Source.zig+++ b/src/browser/webapi/element/html/Source.zig@@ -83,7 +83,7 @@ pub fn selectableSrcset(self: *const Source, frame: *Frame) ?[]const u8 {// Nothing is decoded, so claim the formats a mainstream browser does.fn isSupportedImageType(mime: []const u8) bool {- const essence = std.mem.trim(u8, mime[0 .. std.mem.indexOfScalar(u8, mime, ';') orelse mime.len], &std.ascii.whitespace);+ const essence = std.mem.trim(u8, mime[0 .. std.mem.findScalar(u8, mime, ';') orelse mime.len], &std.ascii.whitespace);if (essence.len == 0) {return true;}diff --git a/src/browser/webapi/element/text_entry.zig b/src/browser/webapi/element/text_entry.zigindex 72f466880..3264dc0a2 100644--- a/src/browser/webapi/element/text_entry.zig+++ b/src/browser/webapi/element/text_entry.zig@@ -252,11 +252,11 @@ pub fn TextEntry(comptime T: type) type {return @intCast(@min(next, value.len));},.line_start => {- const nl = std.mem.lastIndexOfScalar(u8, value[0..pos], '\n') orelse return 0;+ const nl = std.mem.findScalarLast(u8, value[0..pos], '\n') orelse return 0;return @intCast(nl + 1);},.line_end => {- const nl = std.mem.indexOfScalarPos(u8, value, pos, '\n') orelse return @intCast(value.len);+ const nl = std.mem.findScalarPos(u8, value, pos, '\n') orelse return @intCast(value.len);return @intCast(nl);},}diff --git a/src/browser/webapi/encoding/base64.zig b/src/browser/webapi/encoding/base64.zigindex f04653d2d..93bff058c 100644--- a/src/browser/webapi/encoding/base64.zig+++ b/src/browser/webapi/encoding/base64.zig@@ -78,7 +78,7 @@ pub fn decode(alloc: Allocator, in: BinInput) ![]const u8 {// Step 3: a length % 4 == 1 can't represent valid base64.if (src.len % 4 == 1) return error.InvalidCharacterError;// Any "=" still present is misplaced padding.- if (std.mem.indexOfScalar(u8, src, '=') != null) return error.InvalidCharacterError;+ if (std.mem.findScalar(u8, src, '=') != null) return error.InvalidCharacterError;const out_len = src.len / 4 * 3 + switch (src.len % 4) {0 => @as(usize, 0),diff --git a/src/browser/webapi/net/EventSource.zig b/src/browser/webapi/net/EventSource.zigindex 5fed4fbdc..3a432e703 100644--- a/src/browser/webapi/net/EventSource.zig+++ b/src/browser/webapi/net/EventSource.zig@@ -423,7 +423,7 @@ fn parse(self: *EventSource, chunk: []const u8) !void {while (rest.len > 0) {// lines end at CR, LF or CRLF- const idx = std.mem.indexOfAny(u8, rest, "\r\n") orelse {+ const idx = std.mem.findAny(u8, rest, "\r\n") orelse {// no terminator; hold the partial line for the next chunkreturn self.bufferLine(rest);};@@ -474,7 +474,7 @@ fn processLine(self: *EventSource) !void {var field = line;var value: []const u8 = "";- if (std.mem.indexOfScalar(u8, line, ':')) |colon| {+ if (std.mem.findScalar(u8, line, ':')) |colon| {field = line[0..colon];value = line[colon + 1 ..];if (value.len > 0 and value[0] == ' ') {@@ -499,7 +499,7 @@ fn processLine(self: *EventSource) !void {}if (std.mem.eql(u8, field, "id")) {- if (std.mem.indexOfScalar(u8, value, 0) == null) {+ if (std.mem.findScalar(u8, value, 0) == null) {self._id_buf.clearRetainingCapacity();try self._id_buf.appendSlice(arena.allocator(), value);}diff --git a/src/browser/webapi/net/FormData.zig b/src/browser/webapi/net/FormData.zigindex fec52ffb8..3dbc1c56c 100644--- a/src/browser/webapi/net/FormData.zig+++ b/src/browser/webapi/net/FormData.zig@@ -501,7 +501,7 @@ fn parseUrlEncoded(self: *FormData, bytes: []const u8) !void {if (pair.len == 0) {continue;}- if (std.mem.indexOfScalar(u8, pair, '=')) |idx| {+ if (std.mem.findScalar(u8, pair, '=')) |idx| {try self.appendText(try urlDecode(self._arena.allocator(), pair[0..idx]),try urlDecode(self._arena.allocator(), pair[idx + 1 ..]),@@ -519,7 +519,7 @@ fn parseUrlEncoded(self: *FormData, bytes: []const u8) !void {fn indexOfSpecial(slice: []const u8) ?usize {const vector_len = std.simd.suggestVectorLength(u8) orelse {// Non-SIMD path.- return std.mem.indexOfAnyPos(u8, slice, 0, "%+");+ return std.mem.findAnyPos(u8, slice, 0, "%+");};const Vector = @Vector(vector_len, u8);@@ -537,7 +537,7 @@ fn indexOfSpecial(slice: []const u8) ?usize {}}- return std.mem.indexOfAnyPos(u8, slice, end, "%+");+ return std.mem.findAnyPos(u8, slice, end, "%+");}/// URL-decodes passed `raw` slice; returned value may or may not be heap allocated.@@ -700,7 +700,7 @@ fn parseMultipart(self: *FormData, bytes: []const u8, boundary: []const u8, exec// prefix of longer text does not terminate the part.fn indexOfBoundary(haystack: []const u8, boundary: []const u8) ?usize {var start: usize = 0;- while (std.mem.indexOfPos(u8, haystack, start, "\r\n--")) |i| {+ while (std.mem.findPos(u8, haystack, start, "\r\n--")) |i| {const rest = haystack[i + 4 ..];if (std.mem.startsWith(u8, rest, boundary)) {const after = rest[boundary.len..];@@ -716,7 +716,7 @@ fn indexOfBoundary(haystack: []const u8, boundary: []const u8) ?usize {// "Parse a multipart/form-data name": undo writeMultipartName's escapes// (%0A, %0D, %22); any other percent sequence passes through verbatim.fn decodeMultipartName(arena: Allocator, raw: []const u8) ![]const u8 {- if (std.mem.indexOfScalar(u8, raw, '%') == null) {+ if (std.mem.findScalar(u8, raw, '%') == null) {return raw;}diff --git a/src/browser/webapi/net/URLSearchParams.zig b/src/browser/webapi/net/URLSearchParams.zigindex 377bf1b16..52981e140 100644--- a/src/browser/webapi/net/URLSearchParams.zig+++ b/src/browser/webapi/net/URLSearchParams.zig@@ -301,7 +301,7 @@ fn paramsFromString(allocator: Allocator, input_: []const u8, buf: []u8) !KeyValvar name: String = undefined;var value: String = undefined;- if (std.mem.indexOfScalarPos(u8, entry, 0, '=')) |idx| {+ if (std.mem.findScalarPos(u8, entry, 0, '=')) |idx| {name = try unescape(allocator, entry[0..idx], buf);value = try unescape(allocator, entry[idx + 1 ..], buf);} else {diff --git a/src/browser/webapi/net/WebSocket.zig b/src/browser/webapi/net/WebSocket.zigindex c41052d44..ab03b3fa1 100644--- a/src/browser/webapi/net/WebSocket.zig+++ b/src/browser/webapi/net/WebSocket.zig@@ -138,7 +138,7 @@ const BinaryType = enum {pub fn init(url: []const u8, protocols: [][]const u8, exec: *const Execution) !*WebSocket {{- if (std.mem.indexOfScalar(u8, url, '#') != null) {+ if (std.mem.findScalar(u8, url, '#') != null) {// Fragments are not allowed in WebSocket URLs.return error.SyntaxError;}@@ -961,7 +961,7 @@ fn receivedHeaderCallback(buffer: [*]const u8, header_count: usize, buf_len: usiconst header = buffer[0..buf_len];if (self._got_101 == false and std.mem.startsWith(u8, header, "HTTP/")) {- if (std.mem.indexOf(u8, header, " 101 ")) |_| {+ if (std.mem.find(u8, header, " 101 ")) |_| {self._got_101 = true;}return buf_len;@@ -980,7 +980,7 @@ fn receivedHeaderCallback(buffer: [*]const u8, header_count: usize, buf_len: usireturn buf_len;}- const colon = std.mem.indexOfScalarPos(u8, header, 0, ':') orelse {+ const colon = std.mem.findScalarPos(u8, header, 0, ':') orelse {// weird, continue...return buf_len;};diff --git a/src/browser/webapi/net/body_init.zig b/src/browser/webapi/net/body_init.zigindex e622fba38..07528237a 100644--- a/src/browser/webapi/net/body_init.zig+++ b/src/browser/webapi/net/body_init.zig@@ -207,10 +207,10 @@ test "BodyInit: FormData emits multipart with random boundary" {try testing.expectEqual(true, std.mem.startsWith(u8, boundary, "----"));try testing.expectEqual(true, boundary.len > 10);- try testing.expect(std.mem.indexOf(u8, r.bytes, "Content-Disposition: form-data; name=\"username\"") != null);- try testing.expect(std.mem.indexOf(u8, r.bytes, "Content-Disposition: form-data; name=\"email\"") != null);- try testing.expect(std.mem.indexOf(u8, r.bytes, "alice") != null);- try testing.expect(std.mem.indexOf(u8, r.bytes, "[email protected]") != null);+ try testing.expect(std.mem.find(u8, r.bytes, "Content-Disposition: form-data; name=\"username\"") != null);+ try testing.expect(std.mem.find(u8, r.bytes, "Content-Disposition: form-data; name=\"email\"") != null);+ try testing.expect(std.mem.find(u8, r.bytes, "alice") != null);+ try testing.expect(std.mem.find(u8, r.bytes, "[email protected]") != null);const closer = try arena.allocator().print("--{s}--\r\n", .{boundary});try testing.expect(std.mem.endsWith(u8, r.bytes, closer));}diff --git a/src/browser/webapi/selector/List.zig b/src/browser/webapi/selector/List.zigindex 0ff018265..c3c824a70 100644--- a/src/browser/webapi/selector/List.zig+++ b/src/browser/webapi/selector/List.zig@@ -441,7 +441,7 @@ fn matchesAttribute(el: *Node.Element, attr: Selector.Attribute) bool {return if (attr.case_insensitive)std.ascii.findIgnoreCase(value, expected) != nullelse- std.mem.indexOf(u8, value, expected) != null;+ std.mem.find(u8, value, expected) != null;},.starts_with => |expected| {return if (attr.case_insensitive)@@ -492,7 +492,7 @@ fn attributeContainsWord(value: []const u8, word: []const u8) bool {const trimmed = std.mem.trimStart(u8, remaining, &std.ascii.whitespace);if (trimmed.len == 0) return false;- const end = std.mem.indexOfAny(u8, trimmed, &std.ascii.whitespace) orelse trimmed.len;+ const end = std.mem.findAny(u8, trimmed, &std.ascii.whitespace) orelse trimmed.len;const current_word = trimmed[0..end];if (std.mem.eql(u8, current_word, word)) {@@ -651,7 +651,7 @@ fn matchesPseudoClass(el: *Node.Element, pseudo: Selector.PseudoClass, scope: *N// Custom elements.defined => {const tag_name = el.getTagNameLower();- if (std.mem.indexOfScalar(u8, tag_name, '-') == null) return true;+ if (std.mem.findScalar(u8, tag_name, '-') == null) return true;const registry = &frame.window._custom_elements;return registry.get(tag_name) != null;},diff --git a/src/browser/webapi/selector/Parser.zig b/src/browser/webapi/selector/Parser.zigindex 02e2b465a..88352e326 100644--- a/src/browser/webapi/selector/Parser.zig+++ b/src/browser/webapi/selector/Parser.zig@@ -50,7 +50,7 @@ const ParseError = error{// CSS Syntax preprocessing: normalize line endings (CRLF → LF, CR → LF)// https://drafts.csswg.org/css-syntax/#input-preprocessingfn preprocessInput(arena: Allocator, input: []const u8) ![]const u8 {- var i = std.mem.indexOfScalar(u8, input, '\r') orelse return input;+ var i = std.mem.findScalar(u8, input, '\r') orelse return input;var result = try std.ArrayList(u8).initCapacity(arena, input.len);result.appendSliceAssumeCapacity(input[0..i]);diff --git a/src/browser/webapi/selector/Selector.zig b/src/browser/webapi/selector/Selector.zigindex a0194c13a..0d7695738 100644--- a/src/browser/webapi/selector/Selector.zig+++ b/src/browser/webapi/selector/Selector.zig@@ -214,7 +214,7 @@ pub fn classAttributeContains(class_attr: []const u8, class_name: []const u8) bo// single compare, and a token whose first byte differs is rejected without// any boundary or length work.//- // Deliberately not std.mem.indexOfScalarPos: its vector setup costs more+ // Deliberately not std.mem.findScalarPos: its vector setup costs more// than it saves at class-attribute lengths. Measured against it on both the// benchmark shape (~12 bytes) and tailwind-style values (~105 bytes), this// loop wins on every case but one.diff --git a/src/browser/webapi/storage/Cookie.zig b/src/browser/webapi/storage/Cookie.zigindex 35d550178..24727092c 100644--- a/src/browser/webapi/storage/Cookie.zig+++ b/src/browser/webapi/storage/Cookie.zig@@ -138,7 +138,7 @@ pub fn parse(allocator: Allocator, url: [:0]const u8, str: []const u8) !Cookie {var it = std.mem.splitScalar(u8, rest, ';');while (it.next()) |attribute| {- const sep = std.mem.indexOfScalarPos(u8, attribute, 0, '=') orelse attribute.len;+ const sep = std.mem.findScalarPos(u8, attribute, 0, '=') orelse attribute.len;const key_string = trim(attribute[0..sep]);if (key_string.len > scrap.len) {@@ -317,7 +317,7 @@ pub fn parsePath(arena: Allocator, url_: ?[:0]const u8, explicit_path: ?[]const}var owned_path: []const u8 = try percentEncode(arena, url_path, isPathChar);- const last = std.mem.lastIndexOfScalar(u8, owned_path[1..], '/') orelse {+ const last = std.mem.findScalarLast(u8, owned_path[1..], '/') orelse {return "/";};return try arena.dupe(u8, owned_path[0 .. last + 1]);@@ -348,7 +348,7 @@ pub fn parseDomain(arena: Allocator, url_: ?[:0]const u8, explicit_domain: ?[]coreturn error.InvalidDomain;}- if (std.mem.indexOfScalarPos(u8, owned_domain, 1, '.') == null and std.mem.eql(u8, "localhost", owned_domain[1..]) == false) {+ if (std.mem.findScalarPos(u8, owned_domain, 1, '.') == null and std.mem.eql(u8, "localhost", owned_domain[1..]) == false) {// can't set a cookie for a TLDreturn error.InvalidDomain;}@@ -420,10 +420,10 @@ fn isPathChar(c: u8) bool {}fn parseNameValue(str: []const u8) !struct { []const u8, []const u8, []const u8 } {- const key_value_end = std.mem.indexOfScalarPos(u8, str, 0, ';') orelse str.len;+ const key_value_end = std.mem.findScalarPos(u8, str, 0, ';') orelse str.len;const rest = if (key_value_end == str.len) "" else str[key_value_end + 1 ..];- const sep = std.mem.indexOfScalarPos(u8, str[0..key_value_end], 0, '=') orelse {+ const sep = std.mem.findScalarPos(u8, str[0..key_value_end], 0, '=') orelse {const value = trim(str[0..key_value_end]);if (value.len == 0) {return error.Empty;@@ -752,9 +752,9 @@ pub fn areHostsSameSite(target_host: []const u8, origin_host: []const u8) bool {}fn findSecondLevelDomain(host: []const u8) []const u8 {- var i = std.mem.lastIndexOfScalar(u8, host, '.') orelse return host;+ var i = std.mem.findScalarLast(u8, host, '.') orelse return host;while (true) {- i = std.mem.lastIndexOfScalar(u8, host[0..i], '.') orelse return host;+ i = std.mem.findScalarLast(u8, host[0..i], '.') orelse return host;const strip = i + 1;if (public_suffix_list(host[strip..]) == false) {return host[strip..];diff --git a/src/browser/webapi/storage/CookieStore.zig b/src/browser/webapi/storage/CookieStore.zigindex 998f8896e..55ec54579 100644--- a/src/browser/webapi/storage/CookieStore.zig+++ b/src/browser/webapi/storage/CookieStore.zig@@ -443,7 +443,7 @@ fn storeCookie(exec: *const Execution, init_: CookieInit, is_delete: bool) !voidif (init.value.len == 0) {return error.InvalidCookieName;}- if (std.mem.indexOfScalar(u8, init.value, '=') != null) {+ if (std.mem.findScalar(u8, init.value, '=') != null) {return error.InvalidCookieName;}}@@ -451,7 +451,7 @@ fn storeCookie(exec: *const Execution, init_: CookieInit, is_delete: bool) !void// Reject inputs the cookie model can't represent. `=` is allowed in// values but not in names; `;` and the control characters (U+0000–U+001F,// U+007F) break the cookie wire format and so are forbidden in both.- if (std.mem.indexOfScalar(u8, init.name, '=') != null) {+ if (std.mem.findScalar(u8, init.name, '=') != null) {return error.InvalidCookieName;}if (hasForbiddenChar(init.name)) {@@ -470,7 +470,7 @@ fn storeCookie(exec: *const Execution, init_: CookieInit, is_delete: bool) !voidif (init.path.len > 1024) {return error.InvalidCookiePath;}- if (std.mem.indexOfAny(u8, init.path, ";\r\n\x00") != null) {+ if (std.mem.findAny(u8, init.path, ";\r\n\x00") != null) {return error.InvalidCookiePath;}if (init.domain) |d| {@@ -481,7 +481,7 @@ fn storeCookie(exec: *const Execution, init_: CookieInit, is_delete: bool) !voidif (d.len > 1024) {return error.InvalidCookieDomain;}- if (std.mem.indexOfAny(u8, d, ";\r\n\x00") != null) {+ if (std.mem.findAny(u8, d, ";\r\n\x00") != null) {return error.InvalidCookieDomain;}}diff --git a/src/browser/webapi/storage/idb/Key.zig b/src/browser/webapi/storage/idb/Key.zigindex 2b657a678..72c4b8c30 100644--- a/src/browser/webapi/storage/idb/Key.zig+++ b/src/browser/webapi/storage/idb/Key.zig@@ -383,7 +383,7 @@ fn evaluatePath(value: js.Value, key_path: []const u8) ?js.Value {// this before consuming a generated key so a doomed write doesn't advance the// key generator.pub fn canInjectKey(value: js.Value, key_path: []const u8) bool {- const last_dot = std.mem.lastIndexOfScalar(u8, key_path, '.') orelse return value.isObject();+ const last_dot = std.mem.findScalarLast(u8, key_path, '.') orelse return value.isObject();var current = value;var it = std.mem.splitScalar(u8, key_path[0..last_dot], '.');@@ -404,7 +404,7 @@ pub fn canInjectKey(value: js.Value, key_path: []const u8) bool {// Inject a key into a value at a (non-empty) key path, creating intermediate// objects as needed. Requires canInjectKey(value, key_path).pub fn injectKey(local: *const Local, value: js.Value, key_path: []const u8, key: js.Value) !void {- const last_dot = std.mem.lastIndexOfScalar(u8, key_path, '.');+ const last_dot = std.mem.findScalarLast(u8, key_path, '.');const final = if (last_dot) |i| key_path[i + 1 ..] else key_path;var current = value.toObject();diff --git a/src/browser/xpath/functions.zig b/src/browser/xpath/functions.zigindex 94b076422..3a44445bd 100644--- a/src/browser/xpath/functions.zig+++ b/src/browser/xpath/functions.zig@@ -195,14 +195,14 @@ fn containsFn(arena: Allocator, args: []const result.Result) Error!bool {if (args.len < 2) return false;const s1 = try result.toString(arena, args[0]);const s2 = try result.toString(arena, args[1]);- return std.mem.indexOf(u8, s1, s2) != null;+ return std.mem.find(u8, s1, s2) != null;}fn substringBeforeFn(arena: Allocator, args: []const result.Result) Error![]const u8 {if (args.len < 2) return "";const s1 = try result.toString(arena, args[0]);const s2 = try result.toString(arena, args[1]);- if (std.mem.indexOf(u8, s1, s2)) |idx| {+ if (std.mem.find(u8, s1, s2)) |idx| {return s1[0..idx];}return "";@@ -212,7 +212,7 @@ fn substringAfterFn(arena: Allocator, args: []const result.Result) Error![]constif (args.len < 2) return "";const s1 = try result.toString(arena, args[0]);const s2 = try result.toString(arena, args[1]);- if (std.mem.indexOf(u8, s1, s2)) |idx| {+ if (std.mem.find(u8, s1, s2)) |idx| {return s1[idx + s2.len ..];}return "";@@ -289,7 +289,7 @@ fn translateFn(arena: Allocator, args: []const result.Result) Error![]const u8 {var buf = std.Io.Writer.Allocating.init(arena);for (s) |c| {- if (std.mem.indexOfScalar(u8, from, c)) |idx| {+ if (std.mem.findScalar(u8, from, c)) |idx| {// Chars in `from` past `to.len` are deleted (no copy).if (idx < to.len) try buf.writer.writeByte(to[idx]);} else {diff --git a/src/cli.zig b/src/cli.zigindex 9ed8caf9b..cd4641419 100644--- a/src/cli.zig+++ b/src/cli.zig@@ -203,7 +203,7 @@ pub fn tagNames(comptime E: type) []const []const u8 {/// No command or choice has a `.`, `/` or `:`, so `markdown.com` is a url/// however close it is to `markdown`.pub fn isUrlLike(arg: []const u8) bool {- return std.mem.indexOfAny(u8, arg, ".:/") != null;+ return std.mem.findAny(u8, arg, ".:/") != null;}/// `prefix` was stripped from `value` before matching, like `--log-filter`'s sign.diff --git a/src/crash_handler.zig b/src/crash_handler.zigindex 1f6c45a00..9d5a3ed1d 100644--- a/src/crash_handler.zig+++ b/src/crash_handler.zig@@ -596,8 +596,8 @@ fn testSignal(sig: std.posix.SIG, mode: SignalTestMode) !void {try testing.expectEqual(true, std.mem.containsAtLeast(u8, text, 1, address));// The faulting pc alone is not a backtrace: the walk has to have// followed at least one link out of the frame that faulted.- const line = text[std.mem.indexOf(u8, text, "\nbacktrace: ").? + 1 ..];- try testing.expectEqual(true, std.mem.count(u8, line[0..std.mem.indexOfScalar(u8, line, '\n').?], " 0x") >= 2);+ const line = text[std.mem.find(u8, text, "\nbacktrace: ").? + 1 ..];+ try testing.expectEqual(true, std.mem.count(u8, line[0..std.mem.findScalar(u8, line, '\n').?], " 0x") >= 2);} else {try testing.expectEqual(true, std.mem.containsAtLeast(u8, text, 1, "address: unavailable\n"));}diff --git a/src/lightpanda.zig b/src/lightpanda.zigindex c7f8c94a1..90f43aaa9 100644--- a/src/lightpanda.zig+++ b/src/lightpanda.zig@@ -667,7 +667,7 @@ test "writeJsonEnvelope: null frame" {.dump = "",.content = "",}, aw.written());- try testing.expect(std.mem.indexOf(u8, aw.written(), "\"error\":null") != null);+ try testing.expect(std.mem.find(u8, aw.written(), "\"error\":null") != null);}test "writeJsonEnvelope: page error" {diff --git a/src/log.zig b/src/log.zigindex d8387e331..9ed5eed30 100644--- a/src/log.zig+++ b/src/log.zig@@ -637,7 +637,7 @@ fn writeString(format: Format, value: []const u8, writer: *std.Io.Writer) !voidvar rest = value;while (rest.len > 0) {- const pos = std.mem.indexOfAny(u8, rest, "\r\n\"") orelse {+ const pos = std.mem.findAny(u8, rest, "\r\n\"") orelse {try writer.writeAll(rest);break;};@@ -757,13 +757,13 @@ test "log: color disabled (NO_COLOR / non-tty)" {aw.clearRetainingCapacity();try logTo(.app, .info, "test", .{}, &aw.writer);- try testing.expect(std.mem.indexOf(u8, aw.written(), "\x1b") == null);- try testing.expect(std.mem.indexOf(u8, aw.written(), "INFO app : test") != null);+ try testing.expect(std.mem.find(u8, aw.written(), "\x1b") == null);+ try testing.expect(std.mem.find(u8, aw.written(), "INFO app : test") != null);aw.clearRetainingCapacity();try logTo(.app, .err, "test", .{}, &aw.writer);- try testing.expect(std.mem.indexOf(u8, aw.written(), "\x1b") == null);- try testing.expect(std.mem.indexOf(u8, aw.written(), "ERROR app : test") != null);+ try testing.expect(std.mem.find(u8, aw.written(), "\x1b") == null);+ try testing.expect(std.mem.find(u8, aw.written(), "ERROR app : test") != null);}test "log: data" {diff --git a/src/malloc_tuning.zig b/src/malloc_tuning.zigindex 23e165696..fe38cd580 100644--- a/src/malloc_tuning.zig+++ b/src/malloc_tuning.zig@@ -57,7 +57,7 @@ fn userConfigured() bool {return true;}const tunables = std.c.getenv("GLIBC_TUNABLES") orelse return false;- return std.mem.indexOf(u8, std.mem.span(tunables), "glibc.malloc.mmap_threshold") != null;+ return std.mem.find(u8, std.mem.span(tunables), "glibc.malloc.mmap_threshold") != null;}const testing = @import("testing.zig");diff --git a/src/mcp/HttpServer.zig b/src/mcp/HttpServer.zigindex 59989e270..427868594 100644--- a/src/mcp/HttpServer.zig+++ b/src/mcp/HttpServer.zig@@ -486,7 +486,7 @@ fn checkHeaders(arena: std.mem.Allocator, request: *std.http.Server.Request) !?[/// `application/json`, case-insensitive, ignoring parameters (`; charset=`).fn isJsonContentType(content_type: ?[]const u8) bool {const ct = content_type orelse return false;- const end = std.mem.indexOfScalar(u8, ct, ';') orelse ct.len;+ const end = std.mem.findScalar(u8, ct, ';') orelse ct.len;const media_type = std.mem.trim(u8, ct[0..end], " \t");return std.ascii.eqlIgnoreCase(media_type, "application/json");}diff --git a/src/mcp/router.zig b/src/mcp/router.zigindex bbc67380f..b76e39cae 100644--- a/src/mcp/router.zig+++ b/src/mcp/router.zig@@ -49,7 +49,7 @@ pub fn processRequests(server: anytype, reader: *std.Io.Reader, input: ?std.Io.F/// `takeDelimiter` may still block on a partial line, but MCP clients write/// whole lines. A full buffer also returns so StreamTooLong surfaces.fn idleUntilInput(server: anytype, reader: *std.Io.Reader, file: std.Io.File) void {- while (std.mem.indexOfScalar(u8, reader.buffered(), '\n') == null and+ while (std.mem.findScalar(u8, reader.buffered(), '\n') == null andreader.bufferedLen() < reader.buffer.len){const wait_ms = server.idle();@@ -155,7 +155,7 @@ test "MCP.router - handleMessage - synchronous unit tests" {\\{"jsonrpc":"2.0","id":3,"method":"tools/list"});try testing.expectJson(.{ .jsonrpc = "2.0", .id = 3 }, out_alloc.writer.buffered());- try testing.expect(std.mem.indexOf(u8, out_alloc.writer.buffered(), "\"name\":\"goto\"") != null);+ try testing.expect(std.mem.find(u8, out_alloc.writer.buffered(), "\"name\":\"goto\"") != null);out_alloc.writer.end = 0;// 4. Method not founddiff --git a/src/mcp/tools.zig b/src/mcp/tools.zigindex f1d42de05..cf684e64b 100644--- a/src/mcp/tools.zig+++ b/src/mcp/tools.zig@@ -418,7 +418,7 @@ test "MCP - structuredContent on a navigation" {\\};try router.handleMessage(server, testing.arena_allocator, get_url);- try testing.expect(std.mem.indexOf(u8, out.written(), "structuredContent") == null);+ try testing.expect(std.mem.find(u8, out.written(), "structuredContent") == null);// An action reports where it left the page, navigation or not.out.clearRetainingCapacity();@@ -617,7 +617,7 @@ test "MCP - click on a target=_blank link follows the new window" {\\};try router.handleMessage(server, testing.arena_allocator, click);- try testing.expect(std.mem.indexOf(u8, out.written(), "Opened a new window; tools now act on it. Page url: http://localhost:9582/src/browser/tests/mcp_actions.html") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Opened a new window; tools now act on it. Page url: http://localhost:9582/src/browser/tests/mcp_actions.html") != null);out.clearRetainingCapacity();const get_url =@@ -647,7 +647,7 @@ test "MCP - click on a target=_blank link follows the new window" {\\};try router.handleMessage(server, testing.arena_allocator, navigate);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"isError\":false") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"isError\":false") != null);out.clearRetainingCapacity();try router.handleMessage(server, testing.arena_allocator, get_url);@@ -673,7 +673,7 @@ test "MCP - submitting a target=_blank form follows the new window" {\\};try router.handleMessage(server, testing.arena_allocator, click);- try testing.expect(std.mem.indexOf(u8, out.written(), "Opened a new window; tools now act on it. Page url: http://localhost:9582/src/browser/tests/mcp_actions.html?q=1") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Opened a new window; tools now act on it. Page url: http://localhost:9582/src/browser/tests/mcp_actions.html?q=1") != null);}test "MCP - evaluate: localStorage persists across navigations and is origin-scoped" {@@ -1073,8 +1073,8 @@ test "MCP - evaluate: rejected Promise surfaces as is_error" {\\};try router.handleMessage(server, testing.arena_allocator, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"isError\":true") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "nope") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"isError\":true") != null);+ try testing.expect(std.mem.find(u8, out.written(), "nope") != null);}test "MCP - evaluate: async IIFE without explicit return resolves to empty text" {@@ -1144,7 +1144,7 @@ test "MCP - save rejects unsafe path" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"save","arguments":{"path":"../escape.js","script":"goto(\"x\");"}}};try router.handleMessage(server, testing.arena_allocator, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "must be relative") != null);+ try testing.expect(std.mem.find(u8, out.written(), "must be relative") != null);}test "MCP - save writes the script to disk" {@@ -1160,7 +1160,7 @@ test "MCP - save writes the script to disk" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"save","arguments":{"path":"mcp-save-test-script.js","script":"const page = new Page();\nawait page.goto(\"https://example.com\");"}}};try router.handleMessage(server, testing.arena_allocator, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "saved 2 line") != null);+ try testing.expect(std.mem.find(u8, out.written(), "saved 2 line") != null);const written = try std.Io.Dir.cwd().readFileAlloc(lp.io, path, testing.arena_allocator, .limited(4096));try std.testing.expectEqualStrings("const page = new Page();\nawait page.goto(\"https://example.com\");\n", written);@@ -1176,7 +1176,7 @@ test "MCP - tree rejects stale backendNodeId instead of dumping whole document";try router.handleMessage(server, testing.arena_allocator, msg);const written = out.written();- try testing.expect(std.mem.indexOf(u8, written, "NodeNotFound") != null);+ try testing.expect(std.mem.find(u8, written, "NodeNotFound") != null);}test "MCP - tree treats zero-filled backendNodeId as omitted" {@@ -1189,8 +1189,8 @@ test "MCP - tree treats zero-filled backendNodeId as omitted" {;try router.handleMessage(server, testing.arena_allocator, msg);const written = out.written();- try testing.expect(std.mem.indexOf(u8, written, "NodeNotFound") == null);- try testing.expect(std.mem.indexOf(u8, written, "\"isError\":true") == null);+ try testing.expect(std.mem.find(u8, written, "NodeNotFound") == null);+ try testing.expect(std.mem.find(u8, written, "\"isError\":true") == null);}test "MCP - stale backendNodeId surfaces recovery guidance" {@@ -1203,8 +1203,8 @@ test "MCP - stale backendNodeId surfaces recovery guidance" {;try router.handleMessage(server, testing.arena_allocator, msg);const written = out.written();- try testing.expect(std.mem.indexOf(u8, written, "NodeNotFound") != null);- try testing.expect(std.mem.indexOf(u8, written, "omit backendNodeId") != null);+ try testing.expect(std.mem.find(u8, written, "NodeNotFound") != null);+ try testing.expect(std.mem.find(u8, written, "omit backendNodeId") != null);}test "MCP - PascalCase argument keys from LLMs are normalized to canonical" {@@ -1217,8 +1217,8 @@ test "MCP - PascalCase argument keys from LLMs are normalized to canonical" {;try router.handleMessage(server, testing.arena_allocator, msg);const written = out.written();- try testing.expect(std.mem.indexOf(u8, written, "\"isError\":true") == null);- try testing.expect(std.mem.indexOf(u8, written, "InvalidParams") == null);+ try testing.expect(std.mem.find(u8, written, "\"isError\":true") == null);+ try testing.expect(std.mem.find(u8, written, "InvalidParams") == null);}test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setChecked" {@@ -1241,15 +1241,15 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst btn_id_str = std.mem.print(&btn_id_buf, "{d}", .{btn_id}) catch unreachable;const click_msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"click\",\"arguments\":{\"backendNodeId\":", btn_id_str, "}}}" });try router.handleMessage(server, aa, click_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Clicked element") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "Page url: http://localhost:9582/src/browser/tests/mcp_actions.html") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Clicked element") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Page url: http://localhost:9582/src/browser/tests/mcp_actions.html") != null);out.clearRetainingCapacity();}for ([_][]const u8{ "#btnPreventDefault", "#btnDisabled", "#focusTarget", "#plain" }) |selector| {const msg = try aa.print("{{\"jsonrpc\":\"2.0\",\"id\":10,\"method\":\"tools/call\",\"params\":{{\"name\":\"click\",\"arguments\":{{\"selector\":\"{s}\"}}}}}}", .{selector});try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Clicked element") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Clicked element") != null);out.clearRetainingCapacity();}@@ -1260,8 +1260,8 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst inp_id_str = std.mem.print(&inp_id_buf, "{d}", .{inp_id}) catch unreachable;const fill_msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"fill\",\"arguments\":{\"backendNodeId\":", inp_id_str, ",\"value\":\"hello\"}}}" });try router.handleMessage(server, aa, fill_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Filled element") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "with \\\"hello\\\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Filled element") != null);+ try testing.expect(std.mem.find(u8, out.written(), "with \\\"hello\\\"") != null);out.clearRetainingCapacity();}@@ -1272,8 +1272,8 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst sel_id_str = std.mem.print(&sel_id_buf, "{d}", .{sel_id}) catch unreachable;const fill_sel_msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"fill\",\"arguments\":{\"backendNodeId\":", sel_id_str, ",\"value\":\"opt2\"}}}" });try router.handleMessage(server, aa, fill_sel_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Filled element") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "with \\\"opt2\\\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Filled element") != null);+ try testing.expect(std.mem.find(u8, out.written(), "with \\\"opt2\\\"") != null);out.clearRetainingCapacity();}@@ -1287,7 +1287,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst msg = try aa.print("{{\"jsonrpc\":\"2.0\",\"id\":4,\"method\":\"tools/call\",\"params\":{{\"name\":\"scroll\",\"arguments\":{{\"backendNodeId\":{d},\"y\":{d}}}}}}}", .{ c.id, c.y });try router.handleMessage(server, aa, msg);const expected = try aa.print("Scrolled element (backendNodeId: {d}) to x: 0, y: {d}", .{ c.id, c.y });- try testing.expect(std.mem.indexOf(u8, out.written(), expected) != null);+ try testing.expect(std.mem.find(u8, out.written(), expected) != null);out.clearRetainingCapacity();}@@ -1300,7 +1300,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst msg = try aa.print("{{\"jsonrpc\":\"2.0\",\"id\":40,\"method\":\"tools/call\",\"params\":{{\"name\":\"scroll\",\"arguments\":{{\"backendNodeId\":{d},\"y\":30}}}}}}", .{leaf_id});try router.handleMessage(server, aa, msg);const expected = try aa.print("Scrolled scroll container (backendNodeId: {d}) of element (backendNodeId: {d}) to x: 0, y: 30", .{ outer_id, leaf_id });- try testing.expect(std.mem.indexOf(u8, out.written(), expected) != null);+ try testing.expect(std.mem.find(u8, out.written(), expected) != null);out.clearRetainingCapacity();}@@ -1312,7 +1312,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setChecked\\{"jsonrpc":"2.0","id":41,"method":"tools/call","params":{"name":"scroll","arguments":{"selector":"#innerleaf","y":30}}});const expected = try aa.print("Scrolled scroll container (backendNodeId: {d}) of element (selector: #innerleaf) to x: 0, y: 30", .{outer_id});- try testing.expect(std.mem.indexOf(u8, out.written(), expected) != null);+ try testing.expect(std.mem.find(u8, out.written(), expected) != null);out.clearRetainingCapacity();}@@ -1325,7 +1325,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst msg = try aa.print("{{\"jsonrpc\":\"2.0\",\"id\":44,\"method\":\"tools/call\",\"params\":{{\"name\":\"scroll\",\"arguments\":{{\"backendNodeId\":{d},\"y\":30}}}}}}", .{leaf_id});try router.handleMessage(server, aa, msg);const expected = try aa.print("Scrolled scroll container (backendNodeId: {d}) of element (backendNodeId: {d}) to x: 0, y: 30", .{ outer_id, leaf_id });- try testing.expect(std.mem.indexOf(u8, out.written(), expected) != null);+ try testing.expect(std.mem.find(u8, out.written(), expected) != null);out.clearRetainingCapacity();}@@ -1334,12 +1334,12 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedtry router.handleMessage(server, aa,\\{"jsonrpc":"2.0","id":42,"method":"tools/call","params":{"name":"scroll","arguments":{"y":20}}});- try testing.expect(std.mem.indexOf(u8, out.written(), "Scrolled window to x: 0, y: 20") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Scrolled window to x: 0, y: 20") != null);out.clearRetainingCapacity();try router.handleMessage(server, aa,\\{"jsonrpc":"2.0","id":43,"method":"tools/call","params":{"name":"scroll","arguments":{"x":5}}});- try testing.expect(std.mem.indexOf(u8, out.written(), "Scrolled window to x: 5, y: 20") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Scrolled window to x: 5, y: 20") != null);out.clearRetainingCapacity();}@@ -1350,7 +1350,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst id_str = std.mem.print(&id_buf, "{d}", .{el_id}) catch unreachable;const msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":5,\"method\":\"tools/call\",\"params\":{\"name\":\"hover\",\"arguments\":{\"backendNodeId\":", id_str, "}}}" });try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Hovered element") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Hovered element") != null);out.clearRetainingCapacity();}@@ -1361,7 +1361,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst id_str = std.mem.print(&id_buf, "{d}", .{el_id}) catch unreachable;const msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":6,\"method\":\"tools/call\",\"params\":{\"name\":\"press\",\"arguments\":{\"key\":\"Enter\",\"backendNodeId\":", id_str, "}}}" });try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Pressed key") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Pressed key") != null);out.clearRetainingCapacity();}@@ -1372,7 +1372,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst id_str = std.mem.print(&id_buf, "{d}", .{el_id}) catch unreachable;const msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":7,\"method\":\"tools/call\",\"params\":{\"name\":\"selectOption\",\"arguments\":{\"backendNodeId\":", id_str, ",\"value\":\"b\"}}}" });try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Selected option") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Selected option") != null);out.clearRetainingCapacity();}@@ -1383,7 +1383,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst id_str = std.mem.print(&id_buf, "{d}", .{el_id}) catch unreachable;const msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":8,\"method\":\"tools/call\",\"params\":{\"name\":\"setChecked\",\"arguments\":{\"backendNodeId\":", id_str, ",\"checked\":true}}}" });try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "checked") != null);+ try testing.expect(std.mem.find(u8, out.written(), "checked") != null);out.clearRetainingCapacity();}@@ -1394,7 +1394,7 @@ test "MCP - Actions: click, fill, scroll, hover, press, selectOption, setCheckedconst id_str = std.mem.print(&id_buf, "{d}", .{el_id}) catch unreachable;const msg = try std.mem.concat(aa, u8, &.{ "{\"jsonrpc\":\"2.0\",\"id\":9,\"method\":\"tools/call\",\"params\":{\"name\":\"setChecked\",\"arguments\":{\"backendNodeId\":", id_str, ",\"checked\":true}}}" });try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "checked") != null);+ try testing.expect(std.mem.find(u8, out.written(), "checked") != null);out.clearRetainingCapacity();}@@ -1487,8 +1487,8 @@ test "MCP - Actions by selector: hover, selectOption, setChecked" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"hover","arguments":{"selector":"#hoverTarget"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Hovered element") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "selector: #hoverTarget") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Hovered element") != null);+ try testing.expect(std.mem.find(u8, out.written(), "selector: #hoverTarget") != null);out.clearRetainingCapacity();}@@ -1497,8 +1497,8 @@ test "MCP - Actions by selector: hover, selectOption, setChecked" {\\{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"selectOption","arguments":{"selector":"#sel2","value":"c"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Selected option") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "selector: #sel2") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Selected option") != null);+ try testing.expect(std.mem.find(u8, out.written(), "selector: #sel2") != null);out.clearRetainingCapacity();}@@ -1507,8 +1507,8 @@ test "MCP - Actions by selector: hover, selectOption, setChecked" {\\{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"setChecked","arguments":{"selector":"#chk","checked":true}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "checked") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "selector: #chk") != null);+ try testing.expect(std.mem.find(u8, out.written(), "checked") != null);+ try testing.expect(std.mem.find(u8, out.written(), "selector: #chk") != null);out.clearRetainingCapacity();}@@ -1517,8 +1517,8 @@ test "MCP - Actions by selector: hover, selectOption, setChecked" {\\{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"setChecked","arguments":{"selector":"#rad","checked":true}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "checked") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "selector: #rad") != null);+ try testing.expect(std.mem.find(u8, out.written(), "checked") != null);+ try testing.expect(std.mem.find(u8, out.written(), "selector: #rad") != null);out.clearRetainingCapacity();}@@ -1552,7 +1552,7 @@ test "MCP - findElement" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"findElement","arguments":{"role":"button"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Click Me") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Click Me") != null);out.clearRetainingCapacity();}@@ -1561,7 +1561,7 @@ test "MCP - findElement" {\\{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"findElement","arguments":{"name":"click"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Click Me") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Click Me") != null);out.clearRetainingCapacity();}@@ -1570,7 +1570,7 @@ test "MCP - findElement" {\\{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"findElement","arguments":{"role":"slider"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "[]") != null);+ try testing.expect(std.mem.find(u8, out.written(), "[]") != null);out.clearRetainingCapacity();}@@ -1579,7 +1579,7 @@ test "MCP - findElement" {\\{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"findElement","arguments":{}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "error") != null);+ try testing.expect(std.mem.find(u8, out.written(), "error") != null);out.clearRetainingCapacity();}@@ -1588,8 +1588,8 @@ test "MCP - findElement" {\\{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"findElement","arguments":{"name":"/^PREVENT.*default$/i"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "Prevent Default") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "Click Me") == null);+ try testing.expect(std.mem.find(u8, out.written(), "Prevent Default") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Click Me") == null);out.clearRetainingCapacity();}@@ -1598,8 +1598,8 @@ test "MCP - findElement" {\\{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"findElement","arguments":{"name":"/(/"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"isError\":true") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "missing closing parenthesis at offset 1") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"isError\":true") != null);+ try testing.expect(std.mem.find(u8, out.written(), "missing closing parenthesis at offset 1") != null);out.clearRetainingCapacity();}@@ -1608,8 +1608,8 @@ test "MCP - findElement" {\\{"jsonrpc":"2.0","id":8,"method":"tools/call","params":{"name":"findElement","arguments":{"name":"/prevent/g"}}};try router.handleMessage(server, aa, msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"isError\":true") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "unsupported regex flag 'g' in '/prevent/g'") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"isError\":true") != null);+ try testing.expect(std.mem.find(u8, out.written(), "unsupported regex flag 'g' in '/prevent/g'") != null);out.clearRetainingCapacity();}}@@ -1677,23 +1677,23 @@ test "MCP - markdown: full page, selector scope, maxBytes truncation" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"markdown"}};try router.handleMessage(server, testing.arena_allocator, full);- try testing.expect(std.mem.indexOf(u8, out.written(), "Click Me") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "Hover Me") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Click Me") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Hover Me") != null);out.clearRetainingCapacity();const scoped =\\{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"markdown","arguments":{"selector":"#hoverTarget"}}};try router.handleMessage(server, testing.arena_allocator, scoped);- try testing.expect(std.mem.indexOf(u8, out.written(), "Hover Me") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "Click Me") == null);+ try testing.expect(std.mem.find(u8, out.written(), "Hover Me") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Click Me") == null);out.clearRetainingCapacity();const capped =\\{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"markdown","arguments":{"maxBytes":4}}};try router.handleMessage(server, testing.arena_allocator, capped);- try testing.expect(std.mem.indexOf(u8, out.written(), "[truncated]") != null);+ try testing.expect(std.mem.find(u8, out.written(), "[truncated]") != null);}test "MCP - html: full document, selector subtree, backendNodeId subtree" {@@ -1706,9 +1706,9 @@ test "MCP - html: full document, selector subtree, backendNodeId subtree" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"html"}};try router.handleMessage(server, testing.arena_allocator, full);- try testing.expect(std.mem.indexOf(u8, out.written(), "<!DOCTYPE html>") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<form id=\\\"f\\\"") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<input id=\\\"q\\\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<!DOCTYPE html>") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<form id=\\\"f\\\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<input id=\\\"q\\\"") != null);// selector → just that element's outerHTML, no doctype.out.clearRetainingCapacity();@@ -1716,9 +1716,9 @@ test "MCP - html: full document, selector subtree, backendNodeId subtree" {\\{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"html","arguments":{"selector":"#q"}}};try router.handleMessage(server, testing.arena_allocator, sel);- try testing.expect(std.mem.indexOf(u8, out.written(), "<!DOCTYPE html>") == null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<input id=\\\"q\\\"") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<form") == null);+ try testing.expect(std.mem.find(u8, out.written(), "<!DOCTYPE html>") == null);+ try testing.expect(std.mem.find(u8, out.written(), "<input id=\\\"q\\\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<form") == null);}test "MCP - html: maxBytes truncation and strip" {@@ -1730,27 +1730,27 @@ test "MCP - html: maxBytes truncation and strip" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"html"}};try router.handleMessage(server, testing.arena_allocator, full);- try testing.expect(std.mem.indexOf(u8, out.written(), "<script>") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<style>") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "[truncated]") == null);+ try testing.expect(std.mem.find(u8, out.written(), "<script>") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<style>") != null);+ try testing.expect(std.mem.find(u8, out.written(), "[truncated]") == null);out.clearRetainingCapacity();const stripped =\\{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"html","arguments":{"strip":{"js":true,"css":true}}}};try router.handleMessage(server, testing.arena_allocator, stripped);- try testing.expect(std.mem.indexOf(u8, out.written(), "<script>") == null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<style>") == null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<h1>Title</h1>") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<script>") == null);+ try testing.expect(std.mem.find(u8, out.written(), "<style>") == null);+ try testing.expect(std.mem.find(u8, out.written(), "<h1>Title</h1>") != null);out.clearRetainingCapacity();const capped =\\{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"html","arguments":{"maxBytes":20}}};try router.handleMessage(server, testing.arena_allocator, capped);- try testing.expect(std.mem.indexOf(u8, out.written(), "<!DOCTYPE html>") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "<h1>") == null);- try testing.expect(std.mem.indexOf(u8, out.written(), "[truncated]") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<!DOCTYPE html>") != null);+ try testing.expect(std.mem.find(u8, out.written(), "<h1>") == null);+ try testing.expect(std.mem.find(u8, out.written(), "[truncated]") != null);}test "MCP - screenshot: inline image, file, unsafe path" {@@ -1762,13 +1762,13 @@ test "MCP - screenshot: inline image, file, unsafe path" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"screenshot"}};try router.handleMessage(server, testing.arena_allocator, inline_call);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"type\":\"image\"") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"mimeType\":\"image/png\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"type\":\"image\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"mimeType\":\"image/png\"") != null);// base64 of the PNG signature- try testing.expect(std.mem.indexOf(u8, out.written(), "\"data\":\"iVBORw0KGgo") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"isError\":false") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"data\":\"iVBORw0KGgo") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"isError\":false") != null);// Inline images are narrowed to the model-facing limit.- try testing.expect(std.mem.indexOf(u8, out.written(), "PNG, 1280x") != null);+ try testing.expect(std.mem.find(u8, out.written(), "PNG, 1280x") != null);const path = "mcp-screenshot-test.png";std.Io.Dir.cwd().deleteFile(lp.io, path) catch {};@@ -1777,8 +1777,8 @@ test "MCP - screenshot: inline image, file, unsafe path" {out.clearRetainingCapacity();const to_file = "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"screenshot\",\"arguments\":{\"path\":\"" ++ path ++ "\",\"selector\":\"#hoverTarget\"}}}";try router.handleMessage(server, testing.arena_allocator, to_file);- try testing.expect(std.mem.indexOf(u8, out.written(), "Saved 1920x") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"type\":\"image\"") == null);+ try testing.expect(std.mem.find(u8, out.written(), "Saved 1920x") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"type\":\"image\"") == null);const png = try std.Io.Dir.cwd().readFileAlloc(lp.io, path, testing.arena_allocator, .limited(1024 * 1024));try testing.expect(std.mem.startsWith(u8, png, "\x89PNG\r\n\x1a\n"));@@ -1787,7 +1787,7 @@ test "MCP - screenshot: inline image, file, unsafe path" {\\{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"screenshot","arguments":{"path":"../escape.png"}}};try router.handleMessage(server, testing.arena_allocator, unsafe);- try testing.expect(std.mem.indexOf(u8, out.written(), "\"isError\":true") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\"isError\":true") != null);}test "MCP - links: dedup, hidden, text fallback, limit" {@@ -1800,8 +1800,8 @@ test "MCP - links: dedup, hidden, text fallback, limit" {;try router.handleMessage(server, testing.arena_allocator, all);try testing.expectEqual(2, std.mem.count(u8, out.written(), "href"));- try testing.expect(std.mem.indexOf(u8, out.written(), "/second") == null);- try testing.expect(std.mem.indexOf(u8, out.written(), "Third") != null);+ try testing.expect(std.mem.find(u8, out.written(), "/second") == null);+ try testing.expect(std.mem.find(u8, out.written(), "Third") != null);out.clearRetainingCapacity();const limited =@@ -1809,7 +1809,7 @@ test "MCP - links: dedup, hidden, text fallback, limit" {;try router.handleMessage(server, testing.arena_allocator, limited);try testing.expectEqual(1, std.mem.count(u8, out.written(), "href"));- try testing.expect(std.mem.indexOf(u8, out.written(), "/first") != null);+ try testing.expect(std.mem.find(u8, out.written(), "/first") != null);}test "MCP - waitForScript: truthy returns, falsy times out" {@@ -1821,14 +1821,14 @@ test "MCP - waitForScript: truthy returns, falsy times out" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"waitForScript","arguments":{"script":"document.readyState === 'complete'","timeout":2000}}};try router.handleMessage(server, testing.arena_allocator, ok);- try testing.expect(std.mem.indexOf(u8, out.written(), "Script returned truthy") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Script returned truthy") != null);out.clearRetainingCapacity();const timeout =\\{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"waitForScript","arguments":{"script":"false","timeout":50}}};try router.handleMessage(server, testing.arena_allocator, timeout);- try testing.expect(std.mem.indexOf(u8, out.written(), "Timeout") != null);+ try testing.expect(std.mem.find(u8, out.written(), "Timeout") != null);}test "MCP - press Enter on form input triggers submit (lowercase alias)" {@@ -1849,7 +1849,7 @@ test "MCP - press Enter on form input triggers submit (lowercase alias)" {const evaluate_msg = try aa.dupe(u8, "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"evaluate\",\"arguments\":{\"script\":\"window.submitted === true && window.submittedValue === 'hello'\"}}}");try router.handleMessage(server, aa, evaluate_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "true") != null);+ try testing.expect(std.mem.find(u8, out.written(), "true") != null);}test "MCP - getCookies: defaults to current page, url filter, all flag" {@@ -1864,31 +1864,31 @@ test "MCP - getCookies: defaults to current page, url filter, all flag" {\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getCookies"}};try router.handleMessage(server, testing.arena_allocator, default_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "session=abc") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "tracking=xyz") == null);+ try testing.expect(std.mem.find(u8, out.written(), "session=abc") != null);+ try testing.expect(std.mem.find(u8, out.written(), "tracking=xyz") == null);out.clearRetainingCapacity();const url_msg =\\{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"getCookies","arguments":{"url":"http://other.test/"}}};try router.handleMessage(server, testing.arena_allocator, url_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "tracking=xyz") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "session=abc") == null);+ try testing.expect(std.mem.find(u8, out.written(), "tracking=xyz") != null);+ try testing.expect(std.mem.find(u8, out.written(), "session=abc") == null);out.clearRetainingCapacity();const all_msg =\\{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"getCookies","arguments":{"all":true}}};try router.handleMessage(server, testing.arena_allocator, all_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "session=abc") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "tracking=xyz") != null);+ try testing.expect(std.mem.find(u8, out.written(), "session=abc") != null);+ try testing.expect(std.mem.find(u8, out.written(), "tracking=xyz") != null);out.clearRetainingCapacity();const empty_msg =\\{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"getCookies","arguments":{"url":"http://nope.test/"}}};try router.handleMessage(server, testing.arena_allocator, empty_msg);- try testing.expect(std.mem.indexOf(u8, out.written(), "No cookies for http://nope.test/") != null);+ try testing.expect(std.mem.find(u8, out.written(), "No cookies for http://nope.test/") != null);}test "MCP - getCookies without a loaded page refuses instead of dumping the jar" {@@ -1903,8 +1903,8 @@ test "MCP - getCookies without a loaded page refuses instead of dumping the jar";try router.handleMessage(server, testing.arena_allocator, msg);const written = out.written();- try testing.expect(std.mem.indexOf(u8, written, "session=abc") == null);- try testing.expect(std.mem.indexOf(u8, written, "No current page") != null);+ try testing.expect(std.mem.find(u8, written, "session=abc") == null);+ try testing.expect(std.mem.find(u8, written, "No current page") != null);}test "MCP - waitForState with bad state surfaces rich error" {@@ -1917,9 +1917,9 @@ test "MCP - waitForState with bad state surfaces rich error" {;try router.handleMessage(server, testing.arena_allocator, msg);const written = out.written();- try testing.expect(std.mem.indexOf(u8, written, "invalid state 'x'") != null);- try testing.expect(std.mem.indexOf(u8, written, "load") != null);- try testing.expect(std.mem.indexOf(u8, written, "isError\":true") != null);+ try testing.expect(std.mem.find(u8, written, "invalid state 'x'") != null);+ try testing.expect(std.mem.find(u8, written, "load") != null);+ try testing.expect(std.mem.find(u8, written, "isError\":true") != null);}test "MCP - sessions: new, list, attach isolation, close" {@@ -1932,7 +1932,7 @@ test "MCP - sessions: new, list, attach isolation, close" {try router.handleMessage(server, aa,\\{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"session_new","arguments":{"name":"a"}}});- try testing.expect(std.mem.indexOf(u8, out.written(), "session a") != null);+ try testing.expect(std.mem.find(u8, out.written(), "session a") != null);try testing.expect(server.sessions.contains("a"));out.clearRetainingCapacity();@@ -1941,8 +1941,8 @@ test "MCP - sessions: new, list, attach isolation, close" {);// The listing is JSON nested in the tool-result text, so its quotes are// escaped (\"default\").- try testing.expect(std.mem.indexOf(u8, out.written(), "\\\"default\\\"") != null);- try testing.expect(std.mem.indexOf(u8, out.written(), "\\\"a\\\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\\\"default\\\"") != null);+ try testing.expect(std.mem.find(u8, out.written(), "\\\"a\\\"") != null);// Routing a request to "a" (as the Mcp-Session-Id header does) and loading// a page there leaves the default untouched, proving the two are isolated.@@ -1960,13 +1960,13 @@ test "MCP - sessions: new, list, attach isolation, close" {try router.handleMessage(server, aa,\\{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"session_close","arguments":{"id":"default"}}});- try testing.expect(std.mem.indexOf(u8, out.written(), "cannot be closed") != null);+ try testing.expect(std.mem.find(u8, out.written(), "cannot be closed") != null);out.clearRetainingCapacity();try router.handleMessage(server, aa,\\{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"session_close","arguments":{"id":"a"}}});- try testing.expect(std.mem.indexOf(u8, out.written(), "closed session a") != null);+ try testing.expect(std.mem.find(u8, out.written(), "closed session a") != null);try testing.expect(!server.sessions.contains("a"));}diff --git a/src/network/CorsGate.zig b/src/network/CorsGate.zigindex cff54f5de..deea75928 100644--- a/src/network/CorsGate.zig+++ b/src/network/CorsGate.zig@@ -113,7 +113,7 @@ fn hasNoCorsUnsafeBytes(value: []const u8) bool {}fn isSafelistedContentType(value: []const u8) bool {- const semi = std.mem.indexOfScalar(u8, value, ';') orelse value.len;+ const semi = std.mem.findScalar(u8, value, ';') orelse value.len;const mime = std.mem.trim(u8, value[0..semi], &std.ascii.whitespace);return std.ascii.eqlIgnoreCase(mime, "application/x-www-form-urlencoded") orstd.ascii.eqlIgnoreCase(mime, "multipart/form-data") ordiff --git a/src/network/HttpClient.zig b/src/network/HttpClient.zigindex 26eacc5e4..c8d9892f9 100644--- a/src/network/HttpClient.zig+++ b/src/network/HttpClient.zig@@ -4444,7 +4444,7 @@ const Synthetic = struct {}const owner = transfer.owner orelse return error.BlobNotFound;- const key = url[0 .. std.mem.indexOfScalar(u8, url, '#') orelse url.len];+ const key = url[0 .. std.mem.findScalar(u8, url, '#') orelse url.len];if (!Owner.Blob.urlBelongsToOrigin(key, owner.scope.origin())) {return error.BlobNotFound;}diff --git a/src/network/IpFilter.zig b/src/network/IpFilter.zigindex 5e80e24d6..f95d8df16 100644--- a/src/network/IpFilter.zig+++ b/src/network/IpFilter.zig@@ -147,7 +147,7 @@ fn parseIpv4(str: []const u8) ?Ipv4Addr {/// Returns null on parse failure.fn parseIpv6(str: []const u8) ?Ipv6Addr {// Strip zone ID- const clean = if (std.mem.indexOfScalar(u8, str, '%')) |idx| str[0..idx] else str;+ const clean = if (std.mem.findScalar(u8, str, '%')) |idx| str[0..idx] else str;const parsed = std.Io.net.IpAddress.parseIp6(clean, 0) catch return null;return parsed.ip6.bytes;}@@ -219,7 +219,7 @@ pub fn parseCidrList(const is_allow = trimmed[0] == '-';const cidr_part = if (is_allow) trimmed[1..] else trimmed;- const slash = std.mem.indexOfScalar(u8, cidr_part, '/') orelse return error.InvalidCidr;+ const slash = std.mem.findScalar(u8, cidr_part, '/') orelse return error.InvalidCidr;const addr_str = cidr_part[0..slash];const prefix_str = cidr_part[slash + 1 ..];diff --git a/src/network/Robots.zig b/src/network/Robots.zigindex da0b55718..f303db173 100644--- a/src/network/Robots.zig+++ b/src/network/Robots.zig@@ -39,7 +39,7 @@ const CompiledPattern = struct {};}- const is_wildcard = std.mem.indexOfScalar(u8, pattern, '*') != null;+ const is_wildcard = std.mem.findScalar(u8, pattern, '*') != null;if (is_wildcard) {return .{@@ -252,7 +252,7 @@ fn appendContentSignals(var iter = std.mem.splitScalar(u8, value, ',');while (iter.next()) |raw_pair| {const pair = std.mem.trim(u8, raw_pair, &std.ascii.whitespace);- const eq = std.mem.indexOfScalarPos(u8, pair, 0, '=') orelse continue;+ const eq = std.mem.findScalarPos(u8, pair, 0, '=') orelse continue;const name_raw = std.mem.trim(u8, pair[0..eq], &std.ascii.whitespace);const value_raw = std.mem.trim(u8, pair[eq + 1 ..], &std.ascii.whitespace);@@ -309,14 +309,14 @@ fn parseRulesWithUserAgent(if (std.mem.startsWith(u8, trimmed, "#")) continue;// Remove end of line comment.- const true_line = if (std.mem.indexOfScalar(u8, trimmed, '#')) |pos|+ const true_line = if (std.mem.findScalar(u8, trimmed, '#')) |pos|std.mem.trimEnd(u8, trimmed[0..pos], &std.ascii.whitespace)elsetrimmed;if (true_line.len == 0) continue;- const colon_idx = std.mem.indexOfScalar(u8, true_line, ':') orelse {+ const colon_idx = std.mem.findScalar(u8, true_line, ':') orelse {log.debug(.browser, "robots line missing colon", .{ .line = line });continue;};diff --git a/src/network/WebBotAuth.zig b/src/network/WebBotAuth.zigindex 05f54de45..4c8dec7cf 100644--- a/src/network/WebBotAuth.zig+++ b/src/network/WebBotAuth.zig@@ -38,8 +38,8 @@ pub const Config = struct {fn parsePemPrivateKey(pem: []const u8) !*crypto.EVP_PKEY {const begin = "-----BEGIN PRIVATE KEY-----";const end = "-----END PRIVATE KEY-----";- const start_idx = std.mem.indexOf(u8, pem, begin) orelse return error.InvalidPem;- const end_idx = std.mem.indexOf(u8, pem, end) orelse return error.InvalidPem;+ const start_idx = std.mem.find(u8, pem, begin) orelse return error.InvalidPem;+ const end_idx = std.mem.find(u8, pem, end) orelse return error.InvalidPem;const b64 = std.mem.trim(u8, pem[start_idx + begin.len .. end_idx], &std.ascii.whitespace);diff --git a/src/network/adblock/AdBlocker.zig b/src/network/adblock/AdBlocker.zigindex b655bccdd..126e81727 100644--- a/src/network/adblock/AdBlocker.zig+++ b/src/network/adblock/AdBlocker.zig@@ -262,7 +262,7 @@ fn exceptionHostname(line: []const u8, buf: []u8) ?[]const u8 {if (!std.mem.startsWith(u8, line, "@@||")) return null;const rest = line[4..];- const end = std.mem.indexOfAny(u8, rest, "/^$*|") orelse rest.len;+ const end = std.mem.findAny(u8, rest, "/^$*|") orelse rest.len;if (end == 0 or end > buf.len) return null;const hostname = std.ascii.lowerString(buf[0..end], rest[0..end]);@@ -274,7 +274,7 @@ fn exceptionHostname(line: []const u8, buf: []u8) ?[]const u8 {};if (!ok) return null;}- if (std.mem.indexOfScalar(u8, hostname, '.') == null) return null;+ if (std.mem.findScalar(u8, hostname, '.') == null) return null;return hostname;}diff --git a/src/network/adblock/Engine.zig b/src/network/adblock/Engine.zigindex dcda3fece..298f4e6ba 100644--- a/src/network/adblock/Engine.zig+++ b/src/network/adblock/Engine.zig@@ -478,7 +478,7 @@ const RegexShape = struct {'!' => lookaround = .negative,else => {// A named group is a plain group with a label.- const close = std.mem.indexOfScalarPos(u8, self.source, self.i, '>') orelse return error.Unsupported;+ const close = std.mem.findScalarPos(u8, self.source, self.i, '>') orelse return error.Unsupported;self.i = close + 1;},}@@ -557,9 +557,9 @@ const RegexShape = struct {optional = false;},'{' => {- const close = std.mem.indexOfScalarPos(u8, self.source, self.i, '}') orelse return;+ const close = std.mem.findScalarPos(u8, self.source, self.i, '}') orelse return;const body = self.source[self.i + 1 .. close];- const comma = std.mem.indexOfScalar(u8, body, ',') orelse body.len;+ const comma = std.mem.findScalar(u8, body, ',') orelse body.len;// Not a quantifier at all: JavaScript reads the `{` literally.const min = std.fmt.parseUnsigned(usize, body[0..comma], 10) catch return;if (comma + 1 < body.len) _ = std.fmt.parseUnsigned(usize, body[comma + 1 ..], 10) catch return;diff --git a/src/network/adblock/NetworkFilter.zig b/src/network/adblock/NetworkFilter.zigindex 9e23e2862..4e2219e6b 100644--- a/src/network/adblock/NetworkFilter.zig+++ b/src/network/adblock/NetworkFilter.zig@@ -274,7 +274,7 @@ pub fn parse(arena: std.mem.Allocator, line: []const u8) ParseError!NetworkFiltetry filter.parseOptions(arena, options, &explicit_types);}- if (std.mem.indexOfAny(u8, split.pattern, &std.ascii.whitespace) != null) {+ if (std.mem.findAny(u8, split.pattern, &std.ascii.whitespace) != null) {// Whitespace only occurs in hosts-file style lines; anywhere else it// is malformed.if (filter.exception or split.options != null) return error.InvalidPattern;@@ -306,9 +306,9 @@ inline fn isRegexLiteral(text: []const u8) bool {/// "##", "#@#", "#?#", "#$#", "#%#" and their combinations, like "#@$?#".fn hasCosmeticSeparator(text: []const u8) bool {var start: usize = 0;- while (std.mem.indexOfScalarPos(u8, text, start, '#')) |pos| {+ while (std.mem.findScalarPos(u8, text, start, '#')) |pos| {var i = pos + 1;- while (i < text.len and std.mem.indexOfScalar(u8, "@$?%", text[i]) != null) i += 1;+ while (i < text.len and std.mem.findScalar(u8, "@$?%", text[i]) != null) i += 1;if (i < text.len and text[i] == '#') return true;start = pos + 1;}@@ -318,7 +318,7 @@ fn hasCosmeticSeparator(text: []const u8) bool {/// uBO allows a trailing " # comment" on lines containing whitespace.fn stripInlineComment(line: []const u8) []const u8 {var start: usize = 1;- while (std.mem.indexOfScalarPos(u8, line, start, '#')) |pos| {+ while (std.mem.findScalarPos(u8, line, start, '#')) |pos| {if (std.ascii.isWhitespace(line[pos - 1])) {return std.mem.trimEnd(u8, line[0..pos], &std.ascii.whitespace);}@@ -334,7 +334,7 @@ const OptionsSplit = struct {fn splitOptions(line: []const u8) OptionsSplit {var search = line;- while (std.mem.lastIndexOfScalar(u8, search, '$')) |pos| {+ while (std.mem.findScalarLast(u8, search, '$')) |pos| {const suffix = line[pos + 1 ..];if (isOptionListStart(suffix)) {return .{ .pattern = line[0..pos], .options = suffix };@@ -387,7 +387,7 @@ fn parseOptions(}var value: ?[]const u8 = null;- if (std.mem.indexOfScalar(u8, body, '=')) |eq| {+ if (std.mem.findScalar(u8, body, '=')) |eq| {value = body[eq + 1 ..];body = body[0..eq];}@@ -595,7 +595,7 @@ fn parsePattern(return;}- if (std.mem.indexOfScalar(u8, raw, '#') != null) return error.UnsupportedPattern;+ if (std.mem.findScalar(u8, raw, '#') != null) return error.UnsupportedPattern;var pattern = raw;if (std.mem.startsWith(u8, pattern, "||")) {@@ -615,7 +615,7 @@ fn parsePattern(// Trim pointless wildcards touching the (now removed) ends. A wildcard bordering// a short word stays; which is what keeps the word a substring rather than a hostname.- const stars = std.mem.indexOfNone(u8, pattern, "*") orelse pattern.len;+ const stars = std.mem.findNone(u8, pattern, "*") orelse pattern.len;if (stars > 0 and (stars == pattern.len or !isPatternWordChar(pattern[stars]))) {pattern = pattern[stars..];self.left_anchor = false;@@ -637,8 +637,8 @@ fn parsePattern(pattern = try domain.lowered(arena, pattern);if (self.hostname_anchor) {- const host_end = std.mem.indexOfAny(u8, pattern, "/^") orelse pattern.len;- if (std.mem.indexOfScalar(u8, pattern[0..host_end], '*') != null) {+ const host_end = std.mem.findAny(u8, pattern, "/^") orelse pattern.len;+ if (std.mem.findScalar(u8, pattern[0..host_end], '*') != null) {// Wildcard inside the hostname region (`||example.*/ads`):// no hostname split, the whole thing is a generic pattern.self.kind = .wildcard;@@ -658,7 +658,7 @@ fn parsePattern(self.kind = .hostname;self.require_separator = true;} else {- self.kind = if (std.mem.indexOfAny(u8, remainder, "*^") != null) .wildcard else .plain;+ self.kind = if (std.mem.findAny(u8, remainder, "*^") != null) .wildcard else .plain;self.pattern = remainder;}return;@@ -679,7 +679,7 @@ fn parsePattern(return error.InvalidPattern;}- self.kind = if (std.mem.indexOfAny(u8, pattern, "*^") != null) .wildcard else .plain;+ self.kind = if (std.mem.findAny(u8, pattern, "*^") != null) .wildcard else .plain;self.pattern = pattern;}@@ -713,7 +713,7 @@ fn isHostnameShaped(s: []const u8) bool {}if (last.len < 2) return false;if (!std.ascii.isAlphanumeric(last[last.len - 1])) return false;- if (std.mem.indexOfScalar(u8, last, '_') != null) return false;+ if (std.mem.findScalar(u8, last, '_') != null) return false;return true;}diff --git a/src/network/adblock/Parser.zig b/src/network/adblock/Parser.zigindex d69443eb4..8fb938eb0 100644--- a/src/network/adblock/Parser.zig+++ b/src/network/adblock/Parser.zig@@ -145,7 +145,7 @@ const LineClass = enum {}if (line[0] == '|' or std.mem.startsWith(u8, line, "@@|")) return .network;- if (std.mem.indexOf(u8, line, "$$") != null) return .unsupported;+ if (std.mem.find(u8, line, "$$") != null) return .unsupported;return .network;}};diff --git a/src/network/adblock/domain.zig b/src/network/adblock/domain.zigindex 3f2c4dad1..5bec78b17 100644--- a/src/network/adblock/domain.zig+++ b/src/network/adblock/domain.zig@@ -138,9 +138,9 @@ pub fn parse(fn registrable(host: []const u8) []const u8 {if (isIpLiteral(host)) return host;- var i = std.mem.lastIndexOfScalar(u8, host, '.') orelse return host;+ var i = std.mem.findScalarLast(u8, host, '.') orelse return host;while (true) {- i = std.mem.lastIndexOfScalar(u8, host[0..i], '.') orelse return host;+ i = std.mem.findScalarLast(u8, host[0..i], '.') orelse return host;const start = i + 1;if (public_suffix_list.lookup(host[start..]) == false) {return host[start..];@@ -151,7 +151,7 @@ fn registrable(host: []const u8) []const u8 {fn entity(host: []const u8) []const u8 {if (isIpLiteral(host)) return "";const reg = registrable(host);- const dot = std.mem.indexOfScalar(u8, reg, '.') orelse return "";+ const dot = std.mem.findScalar(u8, reg, '.') orelse return "";return reg[0..dot];}diff --git a/src/network/adblock/pattern.zig b/src/network/adblock/pattern.zigindex e04c6a10c..b8a5f8c9e 100644--- a/src/network/adblock/pattern.zig+++ b/src/network/adblock/pattern.zig@@ -45,7 +45,7 @@ pub const Url = struct {/// resume the pattern right where the hostname stops.pub fn init(url: []const u8, raw: []const u8) Url {var start: usize = 0;- if (std.mem.indexOf(u8, url, "://")) |scheme| start = scheme + 3;+ if (std.mem.find(u8, url, "://")) |scheme| start = scheme + 3;var end = url.len;for (url[start..], start..) |c, i| {@@ -59,7 +59,7 @@ pub const Url = struct {}// "user:password@host"- if (std.mem.lastIndexOfScalar(u8, url[start..end], '@')) |at| {+ if (std.mem.findScalarLast(u8, url[start..end], '@')) |at| {start += at + 1;}@@ -68,10 +68,10 @@ pub const Url = struct {const host = url[start..end];var host_end = end;if (host.len > 0 and host[0] == '[') {- if (std.mem.indexOfScalar(u8, host, ']')) |close| {+ if (std.mem.findScalar(u8, host, ']')) |close| {host_end = start + close + 1;}- } else if (std.mem.indexOfScalar(u8, host, ':')) |colon| {+ } else if (std.mem.findScalar(u8, host, ':')) |colon| {host_end = start + colon;}@@ -124,7 +124,7 @@ pub fn matches(filter: *const NetworkFilter, url: Url) bool {var i: usize = url.host_start;while (true) {if (matchFrom(filter, url.text, i, filter.right_anchor)) return true;- const dot = std.mem.indexOfScalarPos(u8, url.text[0..url.host_end], i, '.') orelse+ const dot = std.mem.findScalarPos(u8, url.text[0..url.host_end], i, '.') orelsereturn false;i = dot + 1;}@@ -135,7 +135,7 @@ pub fn matches(filter: *const NetworkFilter, url: Url) bool {}if (filter.kind == .plain) {if (filter.right_anchor) return std.mem.endsWith(u8, url.text, filter.pattern);- return std.mem.indexOf(u8, url.text, filter.pattern) != null;+ return std.mem.find(u8, url.text, filter.pattern) != null;}var i: usize = 0;@@ -157,7 +157,7 @@ fn hostAnchor(url: Url, needle: []const u8, from: usize) ?usize {return url.host_start + p + needle.len;}}- const dot = std.mem.indexOfScalarPos(u8, host, p, '.') orelse return null;+ const dot = std.mem.findScalarPos(u8, host, p, '.') orelse return null;p = dot + 1;}return null;diff --git a/src/network/cache/Cache.zig b/src/network/cache/Cache.zigindex 1735854c4..b136ac8f7 100644--- a/src/network/cache/Cache.zig+++ b/src/network/cache/Cache.zig@@ -151,7 +151,7 @@ pub const ResponseDirectives = struct {// We only care about argument for max-age/s-maxage. For something like// `no-cache="set-cookie"` we ignore it and just treat it as "no-cache"// which is on the safe side.- const name, const argument = if (std.mem.indexOfScalar(u8, directive, '=')) |i|+ const name, const argument = if (std.mem.findScalar(u8, directive, '=')) |i|.{ directive[0..i], directive[i + 1 ..] }else.{ directive, "" };diff --git a/src/network/cache/SqliteCache.zig b/src/network/cache/SqliteCache.zigindex fbe4b48fe..25ce1d6e0 100644--- a/src/network/cache/SqliteCache.zig+++ b/src/network/cache/SqliteCache.zig@@ -1003,7 +1003,7 @@ test "SqliteCache: expired purge uses the cache_expiry index" {defer plan.deinit();const detail = plan.get([]const u8, 3);- if (std.mem.indexOf(u8, detail, "cache_expiry") == null) {+ if (std.mem.find(u8, detail, "cache_expiry") == null) {std.debug.print("query plan: {s}\n", .{detail});return error.FullTableScan;}diff --git a/src/network/header_parser.zig b/src/network/header_parser.zigindex 1009e3481..fa5441d78 100644--- a/src/network/header_parser.zig+++ b/src/network/header_parser.zig@@ -477,8 +477,8 @@ pub fn parseDisposition(value: []const u8) !Disposition {// An unquoted value cannot contain a `;`, so the next one (or the end// of the header) bounds this parameter when it has to be skipped.- const semi = std.mem.indexOfScalar(u8, rest, ';') orelse rest.len;- const eq = std.mem.indexOfScalar(u8, rest, '=') orelse rest.len;+ const semi = std.mem.findScalar(u8, rest, ';') orelse rest.len;+ const eq = std.mem.findScalar(u8, rest, '=') orelse rest.len;if (eq >= semi) {// No `=` in this parameter; skip it.rest = rest[semi..];@@ -492,7 +492,7 @@ pub fn parseDisposition(value: []const u8) !Disposition {rest = rest[semi..];continue;}- const end = std.mem.indexOfScalarPos(u8, after_eq, 1, '"') orelse {+ const end = std.mem.findScalarPos(u8, after_eq, 1, '"') orelse {// Unterminated quoted value; ignore the rest of the header.return disposition;};diff --git a/src/network/http.zig b/src/network/http.zigindex 691f09fa3..b3771d385 100644--- a/src/network/http.zig+++ b/src/network/http.zig@@ -80,7 +80,7 @@ pub const Header = struct {}pub fn parse(header_str: []const u8) ?Header {- const colon_pos = std.mem.indexOfScalar(u8, header_str, ':') orelse return null;+ const colon_pos = std.mem.findScalar(u8, header_str, ':') orelse return null;const name = std.mem.trim(u8, header_str[0..colon_pos], " \t");const value = std.mem.trim(u8, header_str[colon_pos + 1 ..], " \t");@@ -91,13 +91,13 @@ pub const Header = struct {// The header value up to the first ';', trimmed (e.g. "attachment" for a// Content-Disposition, "text/html" for a Content-Type).pub fn firstValue(self: Header) []const u8 {- const end = std.mem.indexOfScalar(u8, self.value, ';') orelse self.value.len;+ const end = std.mem.findScalar(u8, self.value, ';') orelse self.value.len;return std.mem.trim(u8, self.value[0..end], " \t");}// Iterates the `; key=value` parameters that follow the header's first value.pub fn params(self: Header) ParamIterator {- const start = std.mem.indexOfScalar(u8, self.value, ';') orelse self.value.len;+ const start = std.mem.findScalar(u8, self.value, ';') orelse self.value.len;return .{ .rest = self.value[start..] };}@@ -118,11 +118,11 @@ pub const Header = struct {pub fn next(self: *ParamIterator) ?Param {while (self.rest.len > 0 and self.rest[0] == ';') {self.rest = self.rest[1..];- const end = std.mem.indexOfScalar(u8, self.rest, ';') orelse self.rest.len;+ const end = std.mem.findScalar(u8, self.rest, ';') orelse self.rest.len;const segment = self.rest[0..end];self.rest = self.rest[end..];- const eq = std.mem.indexOfScalar(u8, segment, '=') orelse continue;+ const eq = std.mem.findScalar(u8, segment, '=') orelse continue;const key = std.mem.trim(u8, segment[0..eq], " \t");if (key.len == 0) continue;@@ -160,7 +160,7 @@ pub const AuthChallenge = struct {};const challenge_value = std.mem.trim(u8, value, std.ascii.whitespace[0..]);- const pos = std.mem.indexOfPos(u8, challenge_value, 0, " ") orelse challenge_value.len;+ const pos = std.mem.findPos(u8, challenge_value, 0, " ") orelse challenge_value.len;const _scheme = challenge_value[0..pos];if (std.ascii.eqlIgnoreCase(_scheme, "basic")) {ac.scheme = .basic;@@ -184,8 +184,8 @@ pub const StatusText = struct {pub fn fromStatusLine(line: []const u8) StatusText {const trimmed = std.mem.trimEnd(u8, line, "\r\n");// HTTP-version SP status-code SP [ reason-phrase ]- const sp1 = std.mem.indexOfScalar(u8, trimmed, ' ') orelse return .{ ._len = 0 };- const sp2 = std.mem.indexOfScalarPos(u8, trimmed, sp1 + 1, ' ') orelse return .{ ._len = 0 };+ const sp1 = std.mem.findScalar(u8, trimmed, ' ') orelse return .{ ._len = 0 };+ const sp2 = std.mem.findScalarPos(u8, trimmed, sp1 + 1, ' ') orelse return .{ ._len = 0 };const phrase = trimmed[sp2 + 1 ..];const len = @min(phrase.len, MAX_LEN);diff --git a/src/script/Runtime.zig b/src/script/Runtime.zigindex 0b3172bc1..4dfebf932 100644--- a/src/script/Runtime.zig+++ b/src/script/Runtime.zig@@ -1017,7 +1017,7 @@ test "agent script runtime: goto and evaluate dispatch through browser tools" {);const frame = testing.test_session.currentFrame().?;- try testing.expect(std.mem.indexOf(u8, frame.url, "/src/browser/tests/mcp_actions.html") != null);+ try testing.expect(std.mem.find(u8, frame.url, "/src/browser/tests/mcp_actions.html") != null);}test "agent script runtime: Page must be called with new" {@@ -1028,7 +1028,7 @@ test "agent script runtime: Page must be called with new" {defer runtime.deinit();const message = (try runtime.runSource("Page();", "agent-runtime-page-no-new.js")).?;- try testing.expect(std.mem.indexOf(u8, message, "must be called with new") != null);+ try testing.expect(std.mem.find(u8, message, "must be called with new") != null);}test "agent script runtime: a method on an un-navigated page errors" {@@ -1042,7 +1042,7 @@ test "agent script runtime: a method on an un-navigated page errors" {\\const page = new Page();\\page.extract({ btn: "#btn" });, "agent-runtime-not-navigated.js")).?;- try testing.expect(std.mem.indexOf(u8, message, "not navigated") != null);+ try testing.expect(std.mem.find(u8, message, "not navigated") != null);}test "agent script runtime: page.close stales the handle" {@@ -1062,7 +1062,7 @@ test "agent script runtime: page.close stales the handle" {\\page.close();\\page.extract({ btn: "#btn" });, "agent-runtime-close.js")).?;- try testing.expect(std.mem.indexOf(u8, message, "closed") != null);+ try testing.expect(std.mem.find(u8, message, "closed") != null);}test "agent script runtime: parallel gotos coexist and route per page" {@@ -1433,9 +1433,9 @@ test "agent script runtime: tool errors throw and stop execution" {\\globalThis.marker = "after";, "agent-runtime-failure.js")).?;- try testing.expect(std.mem.indexOf(u8, message, "click") != null or- std.mem.indexOf(u8, message, "NodeNotFound") != null or- std.mem.indexOf(u8, message, "#does-not-exist") != null);+ try testing.expect(std.mem.find(u8, message, "click") != null or+ std.mem.find(u8, message, "NodeNotFound") != null or+ std.mem.find(u8, message, "#does-not-exist") != null);try runTestScript(runtime,\\if (globalThis.marker !== "before") throw new Error("script continued after tool failure");@@ -1550,7 +1550,7 @@ test "agent script runtime: builtin argument marshalling (positional + options)"const message = (try runtime.runSource(\\await new Page().goto("http://localhost:9582/src/browser/tests/mcp_actions.html", { url: "http://other" });, "agent-runtime-conflict.js")).?;- try testing.expect(std.mem.indexOf(u8, message, "invalid arguments") != null);+ try testing.expect(std.mem.find(u8, message, "invalid arguments") != null);}// More positionals than the tool has fields throws.@@ -1560,7 +1560,7 @@ test "agent script runtime: builtin argument marshalling (positional + options)"\\await page.goto("http://localhost:9582/src/browser/tests/mcp_actions.html");\\page.click("#btn", "#extra");, "agent-runtime-arity.js")).?;- try testing.expect(std.mem.indexOf(u8, message, "invalid arguments") != null);+ try testing.expect(std.mem.find(u8, message, "invalid arguments") != null);}}diff --git a/src/script/Schema.zig b/src/script/Schema.zigindex e33359c4a..49a53878c 100644--- a/src/script/Schema.zig+++ b/src/script/Schema.zig@@ -238,7 +238,7 @@ pub fn parseValueDiag(self: Schema, arena: std.mem.Allocator, rest_raw: []constlist.appendAssumeCapacity(.{ .key = positional_field.?, .value = stripQuotes(tokens[0]) });}for (tokens[kv_start..]) |tok| {- const eq = std.mem.indexOfScalar(u8, tok, '=') orelse {+ const eq = std.mem.findScalar(u8, tok, '=') orelse {// `/extract save=x '{…}'` — the value would have bound fine as a// leading positional, so point at the ordering instead of the// generic kv complaint.@@ -325,7 +325,7 @@ fn coerce(self: Schema, arena: std.mem.Allocator, key: []const u8, value: []conspub fn splitNameRest(input: []const u8) ?Split {const trimmed = std.mem.trim(u8, input, &std.ascii.whitespace);if (trimmed.len == 0) return null;- const name_end = std.mem.indexOfAny(u8, trimmed, &std.ascii.whitespace) orelse trimmed.len;+ const name_end = std.mem.findAny(u8, trimmed, &std.ascii.whitespace) orelse trimmed.len;return .{.name = trimmed[0..name_end],.rest = std.mem.trimStart(u8, trimmed[name_end..], &std.ascii.whitespace),@@ -507,7 +507,7 @@ fn tokenize(arena: std.mem.Allocator, input: []const u8) ParseError![][]const u8const is_triple = i + 2 < input.len and input[i + 1] == ch and input[i + 2] == ch;if (is_triple) {const triple_delim = input[i .. i + 3];- const close = std.mem.indexOfPos(u8, input, i + 3, triple_delim) orelse return error.UnterminatedQuote;+ const close = std.mem.findPos(u8, input, i + 3, triple_delim) orelse return error.UnterminatedQuote;i = close + 2;} else {// Odd run of `\` before the closer = escape attempt; even = literal.@@ -558,8 +558,8 @@ fn stripQuotes(raw: []const u8) []const u8 {fn looksLikeKv(tok: []const u8) bool {if (tok.len == 0) return false;if (tok[0] == '\'' or tok[0] == '"') return false;- const end = std.mem.indexOfAny(u8, tok, "'\"") orelse tok.len;- const eq = std.mem.indexOfScalar(u8, tok[0..end], '=') orelse return false;+ const end = std.mem.findAny(u8, tok, "'\"") orelse tok.len;+ const eq = std.mem.findScalar(u8, tok[0..end], '=') orelse return false;if (eq == 0) return false;if (!std.ascii.isAlphabetic(tok[0]) and tok[0] != '_') return false;for (tok[1..eq]) |c| {@@ -597,23 +597,23 @@ pub fn hasUnclosedTripleQuote(input: []const u8) bool {pub fn quotedSpanEnd(input: []const u8, start: usize) usize {const ch = input[start];if (start + 2 < input.len and input[start + 1] == ch and input[start + 2] == ch) {- const close = std.mem.indexOfPos(u8, input, start + 3, input[start .. start + 3]) orelse+ const close = std.mem.findPos(u8, input, start + 3, input[start .. start + 3]) orelsereturn input.len;return close + 3;}- const close = std.mem.indexOfScalarPos(u8, input, start + 1, ch) orelse return input.len;+ const close = std.mem.findScalarPos(u8, input, start + 1, ch) orelse return input.len;return close + 1;}/// `body=true`: string is emitted as a `'''…'''` block (newlines OK)./// `body=false`: single-line kv quoting (no newlines representable).pub fn quotableInline(s: []const u8, body: bool) bool {- const has_triple_single = std.mem.indexOf(u8, s, "'''") != null;- const has_triple_double = std.mem.indexOf(u8, s, "\"\"\"") != null;+ const has_triple_single = std.mem.find(u8, s, "'''") != null;+ const has_triple_double = std.mem.find(u8, s, "\"\"\"") != null;if (body) return !(has_triple_single and has_triple_double);- if (std.mem.indexOfScalar(u8, s, '\n') != null) return false;- const has_single = std.mem.indexOfScalar(u8, s, '\'') != null;- const has_double = std.mem.indexOfScalar(u8, s, '"') != null;+ if (std.mem.findScalar(u8, s, '\n') != null) return false;+ const has_single = std.mem.findScalar(u8, s, '\'') != null;+ const has_double = std.mem.findScalar(u8, s, '"') != null;if (has_single and has_double) return !(has_triple_single and has_triple_double);return true;}diff --git a/src/script/command.zig b/src/script/command.zigindex 9263417c4..83acc3dcc 100644--- a/src/script/command.zig+++ b/src/script/command.zig@@ -308,12 +308,12 @@ fn writeExtractSchema(schema_src: []const u8,) (std.Io.Writer.Error || error{OutOfMemory})!void {const parsed = std.json.parseFromSliceLeaky(std.json.Value, arena, schema_src, .{}) catch {- return writeJsValue(arena, writer, .{ .string = schema_src }, .{ .prefer_template = std.mem.indexOfScalar(u8, schema_src, '\n') != null });+ return writeJsValue(arena, writer, .{ .string = schema_src }, .{ .prefer_template = std.mem.findScalar(u8, schema_src, '\n') != null });};if (parsed == .object) {try writeJsValue(arena, writer, parsed, .{});} else {- try writeJsValue(arena, writer, .{ .string = schema_src }, .{ .prefer_template = std.mem.indexOfScalar(u8, schema_src, '\n') != null });+ try writeJsValue(arena, writer, .{ .string = schema_src }, .{ .prefer_template = std.mem.findScalar(u8, schema_src, '\n') != null });}}@@ -330,11 +330,11 @@ fn writeJsonString(writer: *std.Io.Writer, value: []const u8) std.Io.Writer.Erro}fn canUseTemplateLiteral(value: []const u8) bool {- if (std.mem.indexOfScalar(u8, value, '\n') == null) return false;- if (std.mem.indexOfScalar(u8, value, '`') != null) return false;- if (std.mem.indexOf(u8, value, "${") != null) return false;- if (std.mem.indexOfScalar(u8, value, '\\') != null) return false;- if (std.mem.indexOfScalar(u8, value, '\r') != null) return false;+ if (std.mem.findScalar(u8, value, '\n') == null) return false;+ if (std.mem.findScalar(u8, value, '`') != null) return false;+ if (std.mem.find(u8, value, "${") != null) return false;+ if (std.mem.findScalar(u8, value, '\\') != null) return false;+ if (std.mem.findScalar(u8, value, '\r') != null) return false;return true;}diff --git a/src/script/skill.zig b/src/script/skill.zigindex 8de0e5329..590719344 100644--- a/src/script/skill.zig+++ b/src/script/skill.zig@@ -329,25 +329,25 @@ test "skill: every recorded tool is documented, no non-recorded one is" {const body = text();inline for (comptime std.meta.tags(browser_tools.Tool)) |tool| {const call = "page." ++ @tagName(tool) ++ "(";- const documented = std.mem.indexOf(u8, body, call) != null;+ const documented = std.mem.find(u8, body, call) != null;try testing.expect(documented == tool.isRecorded());}- try testing.expect(std.mem.indexOf(u8, body, "await page.goto(") != null);+ try testing.expect(std.mem.find(u8, body, "await page.goto(") != null);}test "skill: golden fragments track the schemas" {const body = text();// waitForState's enum list tracks Config.WaitUntil.inline for (comptime std.meta.tags(lp.Config.WaitUntil)) |state| {- try testing.expect(std.mem.indexOf(u8, body, "\"" ++ @tagName(state) ++ "\"") != null);+ try testing.expect(std.mem.find(u8, body, "\"" ++ @tagName(state) ++ "\"") != null);}- try testing.expect(std.mem.indexOf(u8, body, "`checked` defaults to `true`.") != null);+ try testing.expect(std.mem.find(u8, body, "`checked` defaults to `true`.") != null);// extract's script form takes the schema as its only argument.- try testing.expect(std.mem.indexOf(u8, body, "page.extract(schema)") != null);- try testing.expect(std.mem.indexOf(u8, body, "page.extract(schema[, ") == null);- try testing.expect(std.mem.indexOf(u8, body, "{ url, timeout, save }") != null);+ try testing.expect(std.mem.find(u8, body, "page.extract(schema)") != null);+ try testing.expect(std.mem.find(u8, body, "page.extract(schema[, ") == null);+ try testing.expect(std.mem.find(u8, body, "{ url, timeout, save }") != null);// backendNodeId has no script form.- try testing.expect(std.mem.indexOf(u8, body, "backendNodeId }") == null);+ try testing.expect(std.mem.find(u8, body, "backendNodeId }") == null);}test "skill: write emits frontmatter" {@@ -355,5 +355,5 @@ test "skill: write emits frontmatter" {defer aw.deinit();try write(&aw.writer);try testing.expect(std.mem.startsWith(u8, aw.written(), "---\nname: pandascript\ndescription: "));- try testing.expect(std.mem.indexOf(u8, aw.written(), "\n---\n\n# Writing Lightpanda agent scripts\n") != null);+ try testing.expect(std.mem.find(u8, aw.written(), "\n---\n\n# Writing Lightpanda agent scripts\n") != null);}diff --git a/src/server/Server.zig b/src/server/Server.zigindex fb0641949..b17bb54be 100644--- a/src/server/Server.zig+++ b/src/server/Server.zig@@ -1431,16 +1431,16 @@ test "server: buildJSONVersionResponse" {// The response includes the build version, so check structure rather than exact bytes.try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 200 OK\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "Content-Type: application/json") != null);+ try testing.expect(std.mem.find(u8, res, "Content-Type: application/json") != null);// HTTP connections are kept alive now- try testing.expect(std.mem.indexOf(u8, res, "Connection: Close") == null);+ try testing.expect(std.mem.find(u8, res, "Connection: Close") == null);// Verify all required JSON fields are present in the body- try testing.expect(std.mem.indexOf(u8, res, "\"Browser\": \"Lightpanda/") != null);- try testing.expect(std.mem.indexOf(u8, res, "\"Protocol-Version\": \"1.3\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "\"User-Agent\": \"Lightpanda/") != null);- try testing.expect(std.mem.indexOf(u8, res, "\"Lightpanda-Version\": \"" ++ lp.build_config.version ++ "\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "\"webSocketDebuggerUrl\": \"ws://127.0.0.1:9222/\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"Browser\": \"Lightpanda/") != null);+ try testing.expect(std.mem.find(u8, res, "\"Protocol-Version\": \"1.3\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"User-Agent\": \"Lightpanda/") != null);+ try testing.expect(std.mem.find(u8, res, "\"Lightpanda-Version\": \"" ++ lp.build_config.version ++ "\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"webSocketDebuggerUrl\": \"ws://127.0.0.1:9222/\"") != null);}test "Client: http header past the initial buffer" {@@ -1907,7 +1907,7 @@ test "server: HTTP session outlives its websocket" {try c.bidiCommand("{\"id\":2,\"method\":\"browsingContext.getTree\"}");const res = try c.readWebsocketMessage() orelse return error.NoMessage;defer if (res.cleanup_fragment) c.reader.cleanup();- try testing.expect(std.mem.indexOf(u8, res.data, "\"url\":\"about:blank\"") != null);+ try testing.expect(std.mem.find(u8, res.data, "\"url\":\"about:blank\"") != null);}test "server: HTTP session idle timeout" {@@ -2018,7 +2018,7 @@ test "server: HTTP navigate" {try ws.bidiCommand("{\"id\":1,\"method\":\"browsingContext.getTree\"}");const msg = try ws.readWebsocketMessage() orelse return error.NoMessage;defer if (msg.cleanup_fragment) ws.reader.cleanup();- try testing.expect(std.mem.indexOf(u8, msg.data, "\"url\":\"" ++ url ++ "\"") != null);+ try testing.expect(std.mem.find(u8, msg.data, "\"url\":\"" ++ url ++ "\"") != null);}test "server: HTTP page commands" {@@ -2087,7 +2087,7 @@ test "server: HTTP page commands" {{const res = try sessionCommand(&c, "POST", &session_id, "/actions", "{\"actions\":[{\"type\":\"key\",\"id\":\"kb\",\"actions\":[{\"type\":\"keyDown\"}]}]}");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 400 Bad Request\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"invalid argument\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"invalid argument\"") != null);}// the reload lands on the same document@@ -2148,13 +2148,13 @@ test "server: HTTP element commands" {{const res = try sessionCommand(&c, "GET", &session_id, "/element/99/text", "");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 404 Not Found\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"no such element\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"no such element\"") != null);}{const res = try findElements(&c, &session_id, "css selector", "[");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 400 Bad Request\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"invalid selector\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"invalid selector\"") != null);}const msg = try findElement(&c, &session_id, "css selector", "#msg");@@ -2173,8 +2173,8 @@ test "server: HTTP element commands" {{const body = try elementCommand(&c, &session_id, box, "/rect");try testing.expect(std.mem.startsWith(u8, body, "{\"value\":{\"x\":"));- try testing.expect(std.mem.indexOf(u8, body, "\"width\":40") != null);- try testing.expect(std.mem.indexOf(u8, body, "\"height\":20") != null);+ try testing.expect(std.mem.find(u8, body, "\"width\":40") != null);+ try testing.expect(std.mem.find(u8, body, "\"height\":20") != null);}// a boolean attribute is "true", never its value@@ -2257,7 +2257,7 @@ test "server: HTTP element commands" {const path = try testing.arena_allocator.print("/element/{s}/text", .{msg});const res = try sessionCommand(&c, "GET", &session_id, path, "");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 404 Not Found\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"stale element reference\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"stale element reference\"") != null);}}@@ -2281,7 +2281,7 @@ test "server: HTTP element input" {const gone = try findElement(&c, &session_id, "css selector", "#gone");const res = try elementPost(&c, &session_id, gone, "/click", "{}");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 400 Bad Request\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"element not interactable\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"element not interactable\"") != null);}// clear: focus, the edit's input and change, blur@@ -2298,7 +2298,7 @@ test "server: HTTP element input" {const element = try findElement(&c, &session_id, "css selector", selector);const res = try elementPost(&c, &session_id, element, "/clear", "{}");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 400 Bad Request\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"invalid element state\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"invalid element state\"") != null);}// a modifier stays down until it's typed again@@ -2320,7 +2320,7 @@ test "server: HTTP element input" {const plain = try findElement(&c, &session_id, "css selector", "#plain");const res = try elementPost(&c, &session_id, plain, "/value", "{\"text\":\"x\"}");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 400 Bad Request\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"element not interactable\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"element not interactable\"") != null);}// an option is clicked by selecting it@@ -2426,7 +2426,7 @@ test "server: HTTP execute script" {{const res = try executeRaw(&c, &session_id, "sync", "return 1;", "[{\"" ++ http_command.element_key ++ "\":\"99\"}]");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 404 Not Found\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"no such element\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"no such element\"") != null);}// a node in another document is stale, connected or not@@ -2438,32 +2438,32 @@ test "server: HTTP execute script" {const path = try testing.arena_allocator.print("/element/{s}/text", .{reference});const res = try sessionCommand(&c, "GET", &session_id, path, "");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 404 Not Found\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"stale element reference\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"stale element reference\"") != null);const args = try testing.arena_allocator.print("[{{\"" ++ http_command.element_key ++ "\":\"{s}\"}}]", .{reference});const arg_res = try executeRaw(&c, &session_id, "sync", "return 1;", args);- try testing.expect(std.mem.indexOf(u8, arg_res, "\"error\":\"stale element reference\"") != null);+ try testing.expect(std.mem.find(u8, arg_res, "\"error\":\"stale element reference\"") != null);}// a throw fails the command; it isn't reported inside a successful result{const res = try executeRaw(&c, &session_id, "sync", "throw new Error('nope');", "[]");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 500 Internal Server Error\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"javascript error\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "Error: nope") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"javascript error\"") != null);+ try testing.expect(std.mem.find(u8, res, "Error: nope") != null);}{const res = try executeRaw(&c, &session_id, "sync", "return (", "[]");- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"javascript error\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "SyntaxError") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"javascript error\"") != null);+ try testing.expect(std.mem.find(u8, res, "SyntaxError") != null);}// a cycle is an error, not a collapsed value like a RemoteValue's{const res = try executeRaw(&c, &session_id, "sync", "var a = {}; a.self = a; return a;", "[]");- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"javascript error\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "circular reference") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"javascript error\"") != null);+ try testing.expect(std.mem.find(u8, res, "circular reference") != null);}// a returned promise is resolved before we answer@@ -2474,8 +2474,8 @@ test "server: HTTP execute script" {);{const res = try executeRaw(&c, &session_id, "sync", "return Promise.reject(new Error('late'));", "[]");- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"javascript error\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "Error: late") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"javascript error\"") != null);+ try testing.expect(std.mem.find(u8, res, "Error: late") != null);}// async: the callback is the last argument, and only its first call counts@@ -2499,16 +2499,16 @@ test "server: HTTP execute script" {// not be a *second* answer on a connection we already handed back.{const res = try executeRaw(&c, &session_id, "async", "arguments[0](1); throw new Error('too late');", "[]");- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"javascript error\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "Error: too late") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"javascript error\"") != null);+ try testing.expect(std.mem.find(u8, res, "Error: too late") != null);}try testing.expectEqual("{\"value\":2}", try executeSync(&c, &session_id, "return 2;", "[]"));// a throw before the callback still fails the command{const res = try executeRaw(&c, &session_id, "async", "throw new Error('early');", "[]");- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"javascript error\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "Error: early") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"javascript error\"") != null);+ try testing.expect(std.mem.find(u8, res, "Error: early") != null);}// a script that never completes is answered by the script timeout@@ -2521,11 +2521,11 @@ test "server: HTTP execute script" {const res = try executeRaw(&c, &session_id, "async", "// never calls back", "[]");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 500 Internal Server Error\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"script timeout\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"script timeout\"") != null);// a sync script whose promise never settles times out the same wayconst promise = try executeRaw(&c, &session_id, "sync", "return new Promise(function() {});", "[]");- try testing.expect(std.mem.indexOf(u8, promise, "\"error\":\"script timeout\"") != null);+ try testing.expect(std.mem.find(u8, promise, "\"error\":\"script timeout\"") != null);// A script that resolves AFTER it timed out: answering is not the// promise settling, so the Pending has to outlive its own answer.@@ -2535,7 +2535,7 @@ test "server: HTTP execute script" {// trap, so this covers the path rather than proving the invariant.// selenium/http/demo.js in ../demo is what actually catches it.const late = try executeRaw(&c, &session_id, "async", "var cb = arguments[0]; setTimeout(function() { window.__late = true; cb('way late'); }, 150);", "[]");- try testing.expect(std.mem.indexOf(u8, late, "\"error\":\"script timeout\"") != null);+ try testing.expect(std.mem.find(u8, late, "\"error\":\"script timeout\"") != null);// the assertion only means anything if the stale resolve actually ranvar ran = false;for (0..200) |_| {@@ -2584,8 +2584,8 @@ test "server: HTTP execute script" {, .{handle}));const res = try parked.httpRequest("");- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"javascript error\"") != null);- try testing.expect(std.mem.indexOf(u8, res, "document was unloaded") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"javascript error\"") != null);+ try testing.expect(std.mem.find(u8, res, "document was unloaded") != null);}}@@ -2637,13 +2637,13 @@ fn elementCommand(c: *TestClient, session_id: *const [36]u8, id: []const u8, suf}fn responseBody(res: []const u8) []const u8 {- return res[std.mem.indexOf(u8, res, "\r\n\r\n").? + 4 ..];+ return res[std.mem.find(u8, res, "\r\n\r\n").? + 4 ..];}fn expectWebsocketContains(ws: *TestClient, expected: []const u8) !void {const msg = try ws.readWebsocketMessage() orelse return error.NoMessage;defer if (msg.cleanup_fragment) ws.reader.cleanup();- if (std.mem.indexOf(u8, msg.data, expected) == null) {+ if (std.mem.find(u8, msg.data, expected) == null) {std.debug.print("expected {s} in {s}\n", .{ expected, msg.data });return error.UnexpectedMessage;}@@ -2659,7 +2659,7 @@ test "server: HTTP cookies" {{const res = try sessionCommand(&c, "POST", &session_id, "/cookie", "{\"cookie\":{\"name\":\"a\",\"value\":\"1\"}}");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 400 Bad Request\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"invalid cookie domain\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"invalid cookie domain\"") != null);}const url = "http://127.0.0.1:9582/src/browser/tests/webdriver/elements.html";@@ -2671,12 +2671,12 @@ test "server: HTTP cookies" {{const res = try sessionCommand(&c, "POST", &session_id, "/cookie", "{\"cookie\":{\"name\":\"d\",\"value\":\"4\",\"domain\":\"example.com\"}}");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 400 Bad Request\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"invalid cookie domain\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"invalid cookie domain\"") != null);}{const res = try sessionCommand(&c, "POST", &session_id, "/cookie", "{\"cookie\":{\"name\":\"d\",\"value\":\"4\",\"sameSite\":\"None\"}}");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 500 Internal Server Error\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"unable to set cookie\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"unable to set cookie\"") != null);}// c's path doesn't cover the document, so it isn't the document's@@ -2687,7 +2687,7 @@ test "server: HTTP cookies" {for ([_][]const u8{ "/cookie/c", "/cookie/nope" }) |path| {const res = try sessionCommand(&c, "GET", &session_id, path, "");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 404 Not Found\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "\"error\":\"no such cookie\"") != null);+ try testing.expect(std.mem.find(u8, res, "\"error\":\"no such cookie\"") != null);}// the page sees them, bar the HttpOnly one@@ -2802,7 +2802,7 @@ fn createHTTPSession(body: []const u8, expect_ws_url: bool) ![36]u8 {const res = try c.httpRequest(body);try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 200 OK\r\n"));- const json = res[std.mem.indexOf(u8, res, "\r\n\r\n").? + 4 ..];+ const json = res[std.mem.find(u8, res, "\r\n\r\n").? + 4 ..];const parsed = try std.json.parseFromSlice(std.json.Value, testing.allocator, json, .{});defer parsed.deinit();@@ -3059,9 +3059,9 @@ test "server: get /json/version" {const res1 = try c.httpRequest("GET /json/version HTTP/1.1\r\n\r\n");try testing.expect(std.mem.startsWith(u8, res1, "HTTP/1.1 200 OK\r\n"));- try testing.expect(std.mem.indexOf(u8, res1, "\"Browser\": \"Lightpanda/") != null);- try testing.expect(std.mem.indexOf(u8, res1, "\"Protocol-Version\": \"1.3\"") != null);- try testing.expect(std.mem.indexOf(u8, res1, "\"webSocketDebuggerUrl\": \"ws://127.0.0.1:9583/\"") != null);+ try testing.expect(std.mem.find(u8, res1, "\"Browser\": \"Lightpanda/") != null);+ try testing.expect(std.mem.find(u8, res1, "\"Protocol-Version\": \"1.3\"") != null);+ try testing.expect(std.mem.find(u8, res1, "\"webSocketDebuggerUrl\": \"ws://127.0.0.1:9583/\"") != null);}{@@ -3071,7 +3071,7 @@ test "server: get /json/version" {const res1 = try c.httpRequest("GET /json/version HTTP/1.1\r\n\r\n");try testing.expect(std.mem.startsWith(u8, res1, "HTTP/1.1 200 OK\r\n"));- try testing.expect(std.mem.indexOf(u8, res1, "\"Browser\": \"Lightpanda/") != null);+ try testing.expect(std.mem.find(u8, res1, "\"Browser\": \"Lightpanda/") != null);}}@@ -3083,9 +3083,9 @@ test "server: get /json/protocol" {defer testing.allocator.free(res);try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 200 OK\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "Content-Type: application/json") != null);+ try testing.expect(std.mem.find(u8, res, "Content-Type: application/json") != null);- const body_start = std.mem.indexOf(u8, res, "\r\n\r\n").? + 4;+ const body_start = std.mem.find(u8, res, "\r\n\r\n").? + 4;const parsed = try std.json.parseFromSlice(std.json.Value, testing.allocator, res[body_start..], .{});defer parsed.deinit();@@ -3109,10 +3109,10 @@ test "server: get /metrics" {const res = try c.httpRequest("GET /metrics HTTP/1.1\r\n\r\n");try testing.expect(std.mem.startsWith(u8, res, "HTTP/1.1 200 OK\r\n"));- try testing.expect(std.mem.indexOf(u8, res, "Content-Type: text/plain; version=0.0.4") != null);- try testing.expect(std.mem.indexOf(u8, res, "build_info{version=") != null);- try testing.expect(std.mem.indexOf(u8, res, "# TYPE serve_http_requests_total counter") != null);- try testing.expect(std.mem.indexOf(u8, res, "# TYPE serve_connections_total counter") != null);+ try testing.expect(std.mem.find(u8, res, "Content-Type: text/plain; version=0.0.4") != null);+ try testing.expect(std.mem.find(u8, res, "build_info{version=") != null);+ try testing.expect(std.mem.find(u8, res, "# TYPE serve_http_requests_total counter") != null);+ try testing.expect(std.mem.find(u8, res, "# TYPE serve_connections_total counter") != null);}fn discardBidiMessage(c: *TestClient) !void {@@ -3313,12 +3313,12 @@ const TestClient = struct {// The server keeps HTTP/1.1 connections open, so EOF never marks the end// of a response.fn responseLength(response: []const u8) !?usize {- const header_end = std.mem.indexOf(u8, response, "\r\n\r\n") orelse return null;+ const header_end = std.mem.find(u8, response, "\r\n\r\n") orelse return null;const header = response[0 .. header_end + 4];const cl_header = "Content-Length: ";- const start = (std.mem.indexOf(u8, header, cl_header) orelse return header.len) + cl_header.len;- const end = std.mem.indexOfScalarPos(u8, header, start, '\r') orelse {+ const start = (std.mem.find(u8, header, cl_header) orelse return header.len) + cl_header.len;+ const end = std.mem.findScalarPos(u8, header, start, '\r') orelse {return error.InvalidContentLength;};const cl = std.fmt.parseInt(usize, header[start..end], 10) catch {diff --git a/src/server/bidi/BiDi.zig b/src/server/bidi/BiDi.zigindex 1347767b1..1c2d84a37 100644--- a/src/server/bidi/BiDi.zig+++ b/src/server/bidi/BiDi.zig@@ -322,7 +322,7 @@ pub fn onMessage(self: *BiDi, data: []const u8) anyerror!void {lp.metrics.serve_commands.incr(.bidi);// A BiDi method is always "<module>.<command>".- const i = std.mem.indexOfScalar(u8, method, '.') orelse {+ const i = std.mem.findScalar(u8, method, '.') orelse {return unknownCommand(&cmd, method);};const module = std.meta.stringToEnum(enum {diff --git a/src/server/bidi/browsing_context.zig b/src/server/bidi/browsing_context.zigindex 8bfe00e86..44c0eefa5 100644--- a/src/server/bidi/browsing_context.zig+++ b/src/server/bidi/browsing_context.zig@@ -526,7 +526,7 @@ pub const Locator = union(enum) {const rendered = std.mem.trim(u8, text.written(), &std.ascii.whitespace);break :blk switch (self) {.link_text => std.mem.eql(u8, rendered, needle),- else => std.mem.indexOf(u8, rendered, needle) != null,+ else => std.mem.find(u8, rendered, needle) != null,};},else => unreachable, // css and xpath returned abovediff --git a/src/server/bidi/input.zig b/src/server/bidi/input.zigindex 9fa2614d8..eedcefe61 100644--- a/src/server/bidi/input.zig+++ b/src/server/bidi/input.zig@@ -558,7 +558,7 @@ fn dispatch(bidi: *BiDi, frame: *Frame, source: *Source, action: *const Action)const key = &source.key;const info = keyInfo(cp, key.modifiers.shift);setModifier(&key.modifiers, info.modifier, true);- if (std.mem.indexOfScalar(u21, key.pressed.items, cp) == null) {+ if (std.mem.findScalar(u21, key.pressed.items, cp) == null) {try key.pressed.append(allocator, cp);}try dispatchKey(frame, "keydown", &info, &key.modifiers);@@ -567,14 +567,14 @@ fn dispatch(bidi: *BiDi, frame: *Frame, source: *Source, action: *const Action)const key = &source.key;const info = keyInfo(cp, key.modifiers.shift);setModifier(&key.modifiers, info.modifier, false);- if (std.mem.indexOfScalar(u21, key.pressed.items, cp)) |i| {+ if (std.mem.findScalar(u21, key.pressed.items, cp)) |i| {_ = key.pressed.orderedRemove(i);}try dispatchKey(frame, "keyup", &info, &key.modifiers);},.pointer_down => |button| {const pointer = &source.pointer;- if (std.mem.indexOfScalar(u8, pointer.pressed.items, button) != null) {+ if (std.mem.findScalar(u8, pointer.pressed.items, button) != null) {return; // already down; the spec makes this a no-op}try pointer.pressed.append(allocator, button);@@ -591,7 +591,7 @@ fn dispatch(bidi: *BiDi, frame: *Frame, source: *Source, action: *const Action)},.pointer_up => |button| {const pointer = &source.pointer;- const i = std.mem.indexOfScalar(u8, pointer.pressed.items, button) orelse return;+ const i = std.mem.findScalar(u8, pointer.pressed.items, button) orelse return;_ = pointer.pressed.orderedRemove(i);try user_input.triggerMouseRelease(frame, pointer.x, pointer.y, button, pointer.click_count);},@@ -637,7 +637,7 @@ pub fn typeText(frame: *Frame, text: []const u8) !void {continue;}- if (std.mem.indexOfScalar(u21, held.items, cp)) |i| {+ if (std.mem.findScalar(u21, held.items, cp)) |i| {_ = held.orderedRemove(i);setModifier(&modifiers, info.modifier, false);try dispatchKey(frame, "keyup", &info, &modifiers);diff --git a/src/server/bidi/storage.zig b/src/server/bidi/storage.zigindex 18062d18e..46478b255 100644--- a/src/server/bidi/storage.zig+++ b/src/server/bidi/storage.zig@@ -106,7 +106,7 @@ fn isValidPart(part: []const u8, comptime separators: []const u8) bool {if ((c < 32 and c != '\t') or c > 126) {return false;}- if (std.mem.indexOfScalar(u8, separators, c) != null) {+ if (std.mem.findScalar(u8, separators, c) != null) {return false;}}diff --git a/src/server/cdp/AXNode.zig b/src/server/cdp/AXNode.zigindex 6af12e550..ad6328806 100644--- a/src/server/cdp/AXNode.zig+++ b/src/server/cdp/AXNode.zig@@ -1689,7 +1689,7 @@ test "AXNode: writer prunes hidden and resolves labels" {const value = name_obj.object.get("value") orelse continue;if (value != .string) continue;for (hidden_texts) |bad| {- try testing.expect(std.mem.indexOf(u8, value.string, bad) == null);+ try testing.expect(std.mem.find(u8, value.string, bad) == null);}}@@ -1699,7 +1699,7 @@ test "AXNode: writer prunes hidden and resolves labels" {const obj = node_val.object;const name_obj = obj.get("name") orelse continue;const value = name_obj.object.get("value") orelse continue;- if (value == .string and std.mem.indexOf(u8, value.string, "visible-para") != null) {+ if (value == .string and std.mem.find(u8, value.string, "visible-para") != null) {found_visible = true;break;}@@ -1714,7 +1714,7 @@ test "AXNode: writer prunes hidden and resolves labels" {const role_val = role_obj.object.get("value") orelse continue;if (!std.mem.eql(u8, role_val.string, "searchbox")) continue;const name_val = obj.get("name").?.object.get("value").?;- if (name_val == .string and std.mem.indexOf(u8, name_val.string, "Search") != null) {+ if (name_val == .string and std.mem.find(u8, name_val.string, "Search") != null) {search_named = true;}}@@ -1728,7 +1728,7 @@ test "AXNode: writer prunes hidden and resolves labels" {const role_val = role_obj.object.get("value") orelse continue;if (!std.mem.eql(u8, role_val.string, "textbox")) continue;const name_val = obj.get("name").?.object.get("value").?;- if (name_val == .string and std.mem.indexOf(u8, name_val.string, "Wrap") != null) {+ if (name_val == .string and std.mem.find(u8, name_val.string, "Wrap") != null) {wrapped_named = true;}}@@ -1762,7 +1762,7 @@ test "AXNode: writer prunes hidden and resolves labels" {const name_obj = obj.get("name") orelse continue;const name_value = name_obj.object.get("value") orelse continue;if (name_value != .string) continue;- if (std.mem.indexOf(u8, name_value.string, exp.name_needle) == null) continue;+ if (std.mem.find(u8, name_value.string, exp.name_needle) == null) continue;// Verify the `checked` property was emitted with the right value.const props = obj.get("properties").?.array.items;@@ -2101,8 +2101,8 @@ test "AXNode: writer prunes children when root is hidden" {}, .{});defer testing.allocator.free(json);- try testing.expect(std.mem.indexOf(u8, json, "under-display-none") == null);- try testing.expect(std.mem.indexOf(u8, json, "\"childIds\":[]") != null);+ try testing.expect(std.mem.find(u8, json, "under-display-none") == null);+ try testing.expect(std.mem.find(u8, json, "\"childIds\":[]") != null);}test "AXNode: generic containers share memoized ignore answers" {@@ -2170,7 +2170,7 @@ test "AXNode: aria-hidden is case-insensitive" {}, .{});defer testing.allocator.free(json);- try testing.expect(std.mem.indexOf(u8, json, "hidden-upper") == null);- try testing.expect(std.mem.indexOf(u8, json, "hidden-mixed") == null);- try testing.expect(std.mem.indexOf(u8, json, "visible-false") != null);+ try testing.expect(std.mem.find(u8, json, "hidden-upper") == null);+ try testing.expect(std.mem.find(u8, json, "hidden-mixed") == null);+ try testing.expect(std.mem.find(u8, json, "visible-false") != null);}diff --git a/src/server/cdp/CDP.zig b/src/server/cdp/CDP.zigindex f05d2d486..403f0d78c 100644--- a/src/server/cdp/CDP.zig+++ b/src/server/cdp/CDP.zig@@ -267,7 +267,7 @@ fn dispatchStartupCommand(command: *Command, method: []const u8) !void {fn dispatchCommand(command: *Command, method: []const u8) !void {const domain = blk: {- const i = std.mem.indexOfScalarPos(u8, method, 0, '.') orelse {+ const i = std.mem.findScalarPos(u8, method, 0, '.') orelse {return error.InvalidMethod;};command.input.action = method[i + 1 ..];@@ -426,7 +426,7 @@ pub const BrowserContext = struct {if (log.enabled(.cdp, .debug)) {// msg should be {"method":<method>,...lp.assert(std.mem.startsWith(u8, msg, "{\"method\":"), "onInspectorEvent prefix", .{});- const method_end = std.mem.indexOfScalar(u8, msg, ',') orelse {+ const method_end = std.mem.findScalar(u8, msg, ',') orelse {log.err(.cdp, "invalid inspector event", .{ .msg = msg });return;};@@ -1354,7 +1354,7 @@ pub const IsolatedWorld = struct {}pub fn isSeeded(self: *const IsolatedWorld, frame_id: u32) bool {- return std.mem.indexOfScalar(u32, self.seeded_frames.items, frame_id) != null;+ return std.mem.findScalar(u32, self.seeded_frames.items, frame_id) != null;}// Keyed by Frame, not frame id: a retired root Page keeps its frame iddiff --git a/src/server/cdp/domains/dom.zig b/src/server/cdp/domains/dom.zigindex be70a06aa..4c674bc6c 100644--- a/src/server/cdp/domains/dom.zig+++ b/src/server/cdp/domains/dom.zig@@ -137,7 +137,7 @@ fn isXPathQuery(q: []const u8) bool {// before it must be one of the 13 named axes. Walk back the run of// [a-zA-Z-] characters and look it up in the closed set.var idx: usize = 0;- while (std.mem.indexOfPos(u8, q, idx, "::")) |hit| : (idx = hit + 1) {+ while (std.mem.findPos(u8, q, idx, "::")) |hit| : (idx = hit + 1) {if (hit == 0) continue;var start = hit;while (start > 0) {@@ -739,7 +739,7 @@ fn fileFromDiskPath(path: []const u8, page: *Page) !*File {}fn mimeFromExtension(name: []const u8) []const u8 {- const dot = std.mem.lastIndexOfScalar(u8, name, '.') orelse return "application/octet-stream";+ const dot = std.mem.findScalarLast(u8, name, '.') orelse return "application/octet-stream";if (dot + 1 >= name.len) return "application/octet-stream";var buf: [16]u8 = undefined;const ext_raw = name[dot + 1 ..];diff --git a/src/server/cdp/domains/lp.zig b/src/server/cdp/domains/lp.zigindex aedec0495..1e01737c1 100644--- a/src/server/cdp/domains/lp.zig+++ b/src/server/cdp/domains/lp.zig@@ -575,8 +575,8 @@ test "cdp.lp: dump formats, strip and scoping" {// markdown, no strip: chrome and content both present.try ctx.processMessage(.{ .id = 1, .method = "LP.dump", .params = .{ .format = "markdown" } });var content = try dumpContent(&ctx, 1, "markdown");- try testing.expect(std.mem.indexOf(u8, content, "Site menu") != null);- try testing.expect(std.mem.indexOf(u8, content, "Article body") != null);+ try testing.expect(std.mem.find(u8, content, "Site menu") != null);+ try testing.expect(std.mem.find(u8, content, "Article body") != null);// markdown + shell: chrome gone, the article's own header kept.try ctx.processMessage(.{ .id = 2, .method = "LP.dump", .params = .{ .format = "markdown", .strip = .{ .shell = true } } });@@ -631,10 +631,10 @@ test "cdp.lp: semantic tree and node details read the node's own frame" {try ctx.processMessage(.{ .id = 1, .method = "LP.getSemanticTree", .params = .{ .backendNodeId = html_id, .format = "text", .prune = false } });const tree = (try dumpReply(&ctx, 1)).get("result").?.object.get("semanticTree").?.string;- try testing.expect(std.mem.indexOf(u8, tree, "child-label") != null);- try testing.expect(std.mem.indexOf(u8, tree, "child-option") != null);- try testing.expect(std.mem.indexOf(u8, tree, "child-probe") != null);- try testing.expect(std.mem.indexOf(u8, tree, "parent-") == null);+ try testing.expect(std.mem.find(u8, tree, "child-label") != null);+ try testing.expect(std.mem.find(u8, tree, "child-option") != null);+ try testing.expect(std.mem.find(u8, tree, "child-probe") != null);+ try testing.expect(std.mem.find(u8, tree, "parent-") == null);try ctx.processMessage(.{ .id = 2, .method = "LP.getNodeDetails", .params = .{ .backendNodeId = input_id } });const details = (try dumpReply(&ctx, 2)).get("result").?.object.get("nodeDetails").?.object;@@ -645,8 +645,8 @@ test "cdp.lp: semantic tree and node details read the node's own frame" {try ctx.processMessage(.{ .id = 5, .method = "LP.getSemanticTree", .params = .{ .backendNodeId = html_id, .interactiveOnly = true } });const json = try std.json.Stringify.valueAlloc(testing.allocator, (try dumpReply(&ctx, 5)).get("result").?.object.get("semanticTree").?, .{});defer testing.allocator.free(json);- try testing.expect(std.mem.indexOf(u8, json, "child-label") != null);- try testing.expect(std.mem.indexOf(u8, json, "parent-") == null);+ try testing.expect(std.mem.find(u8, json, "child-label") != null);+ try testing.expect(std.mem.find(u8, json, "parent-") == null);// A document with no frame has no styles or layout to describe.const frameless = try root._factory.genericDocument(.{});diff --git a/src/server/cdp/domains/page.zig b/src/server/cdp/domains/page.zigindex 8791ea23b..4ca5134eb 100644--- a/src/server/cdp/domains/page.zig+++ b/src/server/cdp/domains/page.zig@@ -1937,7 +1937,7 @@ test "cdp.frame: printToPDF" {// Inline base64, landscape: Letter swapped, in points.try ctx.processMessage(.{ .id = 11, .method = "Page.printToPDF", .params = .{ .landscape = true } });const pdf = try pdfResult(&ctx, 11);- try testing.expectEqual(true, std.mem.indexOf(u8, pdf, "/MediaBox [0 0 792.000 612.000]") != null);+ try testing.expectEqual(true, std.mem.find(u8, pdf, "/MediaBox [0 0 792.000 612.000]") != null);}{@@ -2108,7 +2108,7 @@ test "cdp.page: stopLoading finishes a streaming document with what has arrived"_ = try runner.tickForFrame(frame_id, 20, .{});const frame = bc.mainFrame() orelse unreachable;if (bc.session.browser.http_client.findTransfer(frame._req_id)) |transfer| {- if (std.mem.indexOf(u8, transfer.res.buffer.items, "first") != null) {+ if (std.mem.find(u8, transfer.res.buffer.items, "first") != null) {break;}}diff --git a/src/server/http.zig b/src/server/http.zigindex c3ac1badd..762ca8bf8 100644--- a/src/server/http.zig+++ b/src/server/http.zig@@ -139,7 +139,7 @@ pub const Connection = struct {};fn parseHeader(self: *State, arena: Allocator, data: []u8) !Parsed {- const header_index = std.mem.indexOf(u8, data, "\r\n\r\n") orelse {+ const header_index = std.mem.find(u8, data, "\r\n\r\n") orelse {return .{ .need = 0 };};@@ -179,13 +179,13 @@ pub const Connection = struct {const key = "\r\ncontent-length:";const at = std.ascii.findIgnoreCase(header, key) orelse return 0;const start = at + key.len;- const end = std.mem.indexOfPos(u8, header, start, "\r\n") orelse return error.InvalidHeader;+ const end = std.mem.findPos(u8, header, start, "\r\n") orelse return error.InvalidHeader;const value = std.mem.trim(u8, header[start..end], " \t");return std.fmt.parseInt(usize, value, 10) catch error.InvalidHeader;}fn parseRequestLine(header: []const u8) !struct { Method, []const u8, bool, usize } {- const l1 = std.mem.indexOfScalar(u8, header, '\r') orelse return error.InvalidHeader;+ const l1 = std.mem.findScalar(u8, header, '\r') orelse return error.InvalidHeader;if (l1 == header.len) {return error.InvalidHeader;}@@ -202,10 +202,10 @@ pub const Connection = struct {if (target[0] != '/') {return error.InvalidHeader;}- const path = target[0 .. std.mem.indexOfScalar(u8, target, '?') orelse target.len];+ const path = target[0 .. std.mem.findScalar(u8, target, '?') orelse target.len];const protocol = it.next() orelse return error.InvalidHeader;- const keepalive = std.mem.indexOf(u8, protocol, "1.0") == null;+ const keepalive = std.mem.find(u8, protocol, "1.0") == null;return .{ method, path, keepalive, l1 };}diff --git a/src/string.zig b/src/string.zigindex a61703d68..4d9d76bc2 100644--- a/src/string.zig+++ b/src/string.zig@@ -453,7 +453,7 @@ pub fn closest(name: []const u8, candidates: []const []const u8) ?[]const u8 {if (candidates.len == 0) return null;var shared = candidates[0];for (candidates[1..]) |cand| {- shared = shared[0 .. std.mem.indexOfDiff(u8, shared, cand) orelse shared.len];+ shared = shared[0 .. std.mem.findDiff(u8, shared, cand) orelse shared.len];}const typed = if (std.mem.startsWith(u8, name, shared)) name.len - shared.len else name.len;const max_dist = @max(typed, 3) / 3;diff --git a/src/test_runner.zig b/src/test_runner.zigindex d72b210f7..bf307e8b7 100644--- a/src/test_runner.zig+++ b/src/test_runner.zig@@ -118,13 +118,13 @@ const Runner = struct {const is_unnamed_test = isUnnamed(t);if (!is_unnamed_test) {if (self.env.filter) |f| {- if (std.mem.indexOf(u8, t.name, f) == null) {+ if (std.mem.find(u8, t.name, f) == null) {continue;}} else if (webapi_html_test_mode) {// allow filtering by subfilter only, assumes subfilters// only exists for "WebApi: " tests (which is true for now).- if (std.mem.indexOf(u8, t.name, "WebApi: ") == null) {+ if (std.mem.find(u8, t.name, "WebApi: ") == null) {continue;}}@@ -278,7 +278,7 @@ pub fn hasSubfilter() bool {pub fn shouldRun(name: []const u8) bool {const sf = RUNNER.env.subfilter orelse return true;- return std.mem.indexOf(u8, name, sf) != null;+ return std.mem.find(u8, name, sf) != null;}pub fn subtest(name: []const u8) !void {@@ -433,7 +433,7 @@ const Env = struct {const ff = full_filter orelse return .{ null, null };if (ff.len == 0) return .{ null, null };- const split = std.mem.indexOfScalarPos(u8, ff, 0, '#') orelse {+ const split = std.mem.findScalarPos(u8, ff, 0, '#') orelse {return .{ ff, null };};@@ -462,7 +462,7 @@ pub const panic = std.debug.FullPanic(struct {fn isUnnamed(t: std.lang.TestFn) bool {const marker = ".test_";const test_name = t.name;- const index = std.mem.indexOf(u8, test_name, marker) orelse return false;+ const index = std.mem.find(u8, test_name, marker) orelse return false;_ = std.fmt.parseInt(u32, test_name[index + marker.len ..], 10) catch return false;return true;}diff --git a/src/testing.zig b/src/testing.zigindex 09e5dd23a..e1ba6b4c1 100644--- a/src/testing.zig+++ b/src/testing.zig@@ -1350,7 +1350,7 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void {}if (std.mem.startsWith(u8, path, "/src/browser/tests/")) {- if (std.mem.indexOf(u8, path, "delay_ms=")) |pos| {+ if (std.mem.find(u8, path, "delay_ms=")) |pos| {const digits_start = pos + "delay_ms=".len;var end = digits_start;while (end < path.len and std.ascii.isDigit(path[end])) : (end += 1) {}