diff --git a/src/env_loader.zig b/src/env_loader.zig index 36e85e01f0..03c50db57c 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -140,6 +140,7 @@ pub const Loader = struct { } // NO_PROXY filter + // See the syntax at https://about.gitlab.com/blog/2021/01/27/we-need-to-talk-no-proxy/ if (http_proxy != null) { if (this.map.get("no_proxy") orelse this.map.get("NO_PROXY")) |no_proxy_text| { if (no_proxy_text.len == 0 or strings.eqlComptime(no_proxy_text, "\"\"") or strings.eqlComptime(no_proxy_text, "''")) { @@ -149,7 +150,7 @@ pub const Loader = struct { var no_proxy_list = std.mem.split(u8, no_proxy_text, ","); var next = no_proxy_list.next(); while (next != null) { - var host = next.?; + var host = strings.trim(next.?, &strings.whitespace_chars); if (strings.eql(host, "*")) { return null; } diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 63767bcfae..dcf87a89f7 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -4374,10 +4374,14 @@ pub fn trim(slice: anytype, comptime values_to_strip: []const u8) @TypeOf(slice) return slice[begin..end]; } +pub const whitespace_chars = [_]u8{ ' ', '\t', '\n', '\r', std.ascii.control_code.vt, std.ascii.control_code.ff }; + pub fn lengthOfLeadingWhitespaceASCII(slice: string) usize { for (slice) |*c| { switch (c.*) { - ' ', '\t', '\n', '\r', std.ascii.control_code.vt, std.ascii.control_code.ff => {}, + whitespace: { + inline for (whitespace_chars) |wc| break :whitespace wc; + } => {}, else => { return @intFromPtr(c) - @intFromPtr(slice.ptr); },