This commit is contained in:
Karl Seguin
2025-12-16 17:54:14 +08:00
parent 8a2641d213
commit 761b35b199
4 changed files with 3 additions and 5 deletions

View File

@@ -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;
// 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:")) {
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
const host_part = raw[authority_start..authority_end];
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)
for (port) |c| {

View File

@@ -144,7 +144,6 @@ fn httpErrorCallback(ctx: *anyopaque, err: anyerror) void {
self._resolver.reject("fetch error", @errorName(err));
}
const testing = @import("../../../testing.zig");
test "WebApi: fetch" {
try testing.htmlRunner("net/fetch.html", .{});

View File

@@ -59,7 +59,7 @@ const Credentials = enum {
const Cache = enum {
default,
@"no-store",
@"reload",
reload,
@"no-cache",
@"force-cache",
@"only-if-cached",

View File

@@ -113,7 +113,6 @@ pub fn isOK(self: *const Response) bool {
return self._status >= 200 and self._status <= 299;
}
pub fn getText(self: *const Response, page: *Page) !js.Promise {
const body = self._body orelse "";
return page.js.resolvePromise(body);