Handle whitespace in no_proxy environment variable (#7072)

De facto standard format of no_proxy enivronment
variable allows whitespace around the host names.
Make it work.

Closes #6339
This commit is contained in:
Mike Dotty
2023-11-16 06:55:31 +01:00
committed by GitHub
parent 15e4f1bad3
commit 904134cc75
2 changed files with 7 additions and 2 deletions

View File

@@ -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);
},