| ... | ... | @@ -497,7 +497,7 @@ pub const URL = struct { |
| 497 | 497 | if (buffer.items.len > 0) { |
| 498 | 498 | // 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. |
| 499 | 499 | // 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; |
| 501 | 501 | // 3. Set url’s port to null, if port is url’s scheme’s default port; otherwise to port. |
| 502 | 502 | if (schemeDefaultPort(href.items(0)) != p) try href.print(9, "{d}", .{p}); |
| 503 | 503 | // 4. Set buffer to the empty string. |
| ... | ... | @@ -962,7 +962,7 @@ pub const URL = struct { |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | 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; |
| 966 | 966 | const s = u.scheme(); |
| 967 | 967 | if (std.mem.eql(u8, s, "ftp")) return 21; |
| 968 | 968 | if (std.mem.eql(u8, s, "file")) return null; |
| ... | ... | @@ -1250,7 +1250,7 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 { |
| 1250 | 1250 | if (input[i] == '%') { |
| 1251 | 1251 | if (input.len >= i + 1 + 2) { |
| 1252 | 1252 | 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); |
| 1254 | 1254 | i += 2; |
| 1255 | 1255 | continue; |
| 1256 | 1256 | } |
| ... | ... | @@ -1401,7 +1401,7 @@ fn parseIPv4Number(input_: []const u8, T: type) !T { |
| 1401 | 1401 | // 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. |
| 1402 | 1402 | // 9. Return (output, validationError). |
| 1403 | 1403 | 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; |
| 1405 | 1405 | return output; |
| 1406 | 1406 | } |
| 1407 | 1407 | |