Skip to content

Commit 60f4eab

Browse files
committed
handle no params
1 parent d7656ea commit 60f4eab

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/cdp/domains/network.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ fn deleteCookies(cmd: anytype) !void {
132132
}
133133

134134
fn clearBrowserCookies(cmd: anytype) !void {
135+
if (try cmd.params(struct {}) != null) return error.InvalidParams;
135136
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
136137
bc.session.cookie_jar.clearRetainingCapacity();
137138
return cmd.sendResult(null, .{});
@@ -161,11 +162,10 @@ fn setCookies(cmd: anytype) !void {
161162
try cmd.sendResult(null, .{});
162163
}
163164

165+
const GetCookiesParam = struct { urls: ?[]const []const u8 = null };
164166
fn getCookies(cmd: anytype) !void {
165167
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
166-
const params = (try cmd.params(struct {
167-
urls: ?[]const []const u8 = null,
168-
})) orelse return error.InvalidParams;
168+
const params = (try cmd.params(GetCookiesParam)) orelse GetCookiesParam{};
169169

170170
// If not specified, use the URLs of the page and all of its subframes. TODO subframes
171171
const page_url = if (bc.session.page) |*page| page.url.raw else null; // @speed: avoid repasing the URL

src/cdp/domains/storage.zig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ pub fn processMessage(cmd: anytype) !void {
3838
}
3939
}
4040

41+
const BrowserContextParam = struct { browserContextId: ?[]const u8 = null };
42+
4143
fn clearCookies(cmd: anytype) !void {
4244
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
43-
const params = (try cmd.params(struct {
44-
browserContextId: ?[]const u8 = null,
45-
})) orelse return error.InvalidParams;
45+
const params = (try cmd.params(BrowserContextParam)) orelse BrowserContextParam{};
4646

4747
if (params.browserContextId) |browser_context_id| {
4848
if (std.mem.eql(u8, browser_context_id, bc.id) == false) {
@@ -57,9 +57,7 @@ fn clearCookies(cmd: anytype) !void {
5757

5858
fn getCookies(cmd: anytype) !void {
5959
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
60-
const params = (try cmd.params(struct {
61-
browserContextId: ?[]const u8 = null,
62-
})) orelse return error.InvalidParams;
60+
const params = (try cmd.params(BrowserContextParam)) orelse BrowserContextParam{};
6361

6462
if (params.browserContextId) |browser_context_id| {
6563
if (std.mem.eql(u8, browser_context_id, bc.id) == false) {

0 commit comments

Comments
 (0)