mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
zig fmt
This commit is contained in:
@@ -243,7 +243,7 @@ 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.indexOf(u8, raw, "://") orelse return null;
|
||||||
|
|
||||||
// Only HTTP and HTTPS schemes have origins
|
// Only HTTP and HTTPS schemes have origins
|
||||||
const protocol = raw[0..scheme_end + 1];
|
const protocol = raw[0 .. scheme_end + 1];
|
||||||
if (!std.mem.eql(u8, protocol, "http:") and !std.mem.eql(u8, protocol, "https:")) {
|
if (!std.mem.eql(u8, protocol, "http:") and !std.mem.eql(u8, protocol, "https:")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ pub fn getOrigin(allocator: Allocator, raw: [:0]const u8) !?[]const u8 {
|
|||||||
// Check for port in the host:port section
|
// Check for port in the host:port section
|
||||||
const host_part = raw[authority_start..authority_end];
|
const host_part = raw[authority_start..authority_end];
|
||||||
if (std.mem.lastIndexOfScalar(u8, host_part, ':')) |colon_pos_in_host| {
|
if (std.mem.lastIndexOfScalar(u8, host_part, ':')) |colon_pos_in_host| {
|
||||||
const port = host_part[colon_pos_in_host + 1..];
|
const port = host_part[colon_pos_in_host + 1 ..];
|
||||||
|
|
||||||
// Validate it's actually a port (all digits)
|
// Validate it's actually a port (all digits)
|
||||||
for (port) |c| {
|
for (port) |c| {
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ fn httpErrorCallback(ctx: *anyopaque, err: anyerror) void {
|
|||||||
self._resolver.reject("fetch error", @errorName(err));
|
self._resolver.reject("fetch error", @errorName(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const testing = @import("../../../testing.zig");
|
const testing = @import("../../../testing.zig");
|
||||||
test "WebApi: fetch" {
|
test "WebApi: fetch" {
|
||||||
try testing.htmlRunner("net/fetch.html", .{});
|
try testing.htmlRunner("net/fetch.html", .{});
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ const Credentials = enum {
|
|||||||
const Cache = enum {
|
const Cache = enum {
|
||||||
default,
|
default,
|
||||||
@"no-store",
|
@"no-store",
|
||||||
@"reload",
|
reload,
|
||||||
@"no-cache",
|
@"no-cache",
|
||||||
@"force-cache",
|
@"force-cache",
|
||||||
@"only-if-cached",
|
@"only-if-cached",
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ pub fn isOK(self: *const Response) bool {
|
|||||||
return self._status >= 200 and self._status <= 299;
|
return self._status >= 200 and self._status <= 299;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn getText(self: *const Response, page: *Page) !js.Promise {
|
pub fn getText(self: *const Response, page: *Page) !js.Promise {
|
||||||
const body = self._body orelse "";
|
const body = self._body orelse "";
|
||||||
return page.js.resolvePromise(body);
|
return page.js.resolvePromise(body);
|
||||||
|
|||||||
Reference in New Issue
Block a user