authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-12 02:23:28 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-12 02:23:28 -08:00
log8c186c6734cae85182ef5906fb1e159e58a8375d
tree8181ddf4f6f74d1f8e6b42b7d2139b9a3708bf25
parent461819322ec0219d420ba3c4415b5d9e1d9bb502

use extras.parseDigits


1 files changed, 4 insertions(+), 4 deletions(-)

url.zig+4-4
......@@ -497,7 +497,7 @@ pub const URL = struct {
497497 if (buffer.items.len > 0) {
498498 // 1. Let port be the mathematical integer value that is represented by buffer in radix-10 using ASCII digits for digits with values 0 through 9.
499499 // 2. If port is not a 16-bit unsigned integer, port-out-of-range validation error, return failure.
500 const p = std.fmt.parseInt(u16, buffer.items, 10) catch return error.InvalidURL;
500 const p = extras.parseDigits(u16, buffer.items, 10) catch return error.InvalidURL;
501501 // 3. Set url’s port to null, if port is url’s scheme’s default port; otherwise to port.
502502 if (schemeDefaultPort(href.items(0)) != p) try href.print(9, "{d}", .{p});
503503 // 4. Set buffer to the empty string.
......@@ -962,7 +962,7 @@ pub const URL = struct {
962962 }
963963
964964 pub fn portFancy(u: *const URL) ?u16 {
965 if (u.port.len > 0) return std.fmt.parseUnsigned(u16, u.port, 10) catch unreachable;
965 if (u.port.len > 0) return extras.parseDigits(u16, u.port, 10) catch unreachable;
966966 const s = u.scheme();
967967 if (std.mem.eql(u8, s, "ftp")) return 21;
968968 if (std.mem.eql(u8, s, "file")) return null;
......@@ -1250,7 +1250,7 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 {
12501250 if (input[i] == '%') {
12511251 if (input.len >= i + 1 + 2) {
12521252 if (std.ascii.isHex(input[i + 1]) and std.ascii.isHex(input[i + 2])) {
1253 try result.append(std.fmt.parseInt(u8, input[i + 1 ..][0..2], 16) catch unreachable);
1253 try result.append(extras.parseDigits(u8, input[i + 1 ..][0..2], 16) catch unreachable);
12541254 i += 2;
12551255 continue;
12561256 }
......@@ -1401,7 +1401,7 @@ fn parseIPv4Number(input_: []const u8, T: type) !T {
14011401 // 8. Let output be the mathematical integer value that is represented by input in radix-R notation, using ASCII hex digits for digits with values 0 through 15.
14021402 // 9. Return (output, validationError).
14031403 if (T == void) return;
1404 const output = std.fmt.parseInt(T, input, radix) catch return error.Invalid;
1404 const output = extras.parseDigits(T, input, radix) catch return error.Invalid;
14051405 return output;
14061406}
14071407