authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-03 20:52:21 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-03 20:52:21 -08:00
loge2acea4c625c5bab60a034895e05304a9778bf79
tree9500e81c54f385ff48fd3454a25632d3bebb63da
parentf183818589f0ee910ba024c2086aec9cad3366d8

pub some common methods


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

url.zig+13-13
...@@ -1050,7 +1050,7 @@ fn parseHost(allocator: std.mem.Allocator, input: []u8, isOpaque: bool) !URL.Hos...@@ -1050,7 +1050,7 @@ fn parseHost(allocator: std.mem.Allocator, input: []u8, isOpaque: bool) !URL.Hos
1050}1050}
10511051
1052/// https://url.spec.whatwg.org/#concept-ipv6-parser1052/// https://url.spec.whatwg.org/#concept-ipv6-parser
1053fn parseIPv6(input: []const u8) !u128 {1053pub fn parseIPv6(input: []const u8) !u128 {
1054 // 1. Let address be a new IPv6 address whose pieces are all 0.1054 // 1. Let address be a new IPv6 address whose pieces are all 0.
1055 var address: [8]u16 = @splat(0);1055 var address: [8]u16 = @splat(0);
1056 _ = &address;1056 _ = &address;
...@@ -1286,7 +1286,7 @@ fn endsInANumber(input: []const u8) bool {...@@ -1286,7 +1286,7 @@ fn endsInANumber(input: []const u8) bool {
1286}1286}
12871287
1288/// https://url.spec.whatwg.org/#concept-ipv4-parser1288/// https://url.spec.whatwg.org/#concept-ipv4-parser
1289fn parseIPv4(input: []const u8) !u32 {1289pub fn parseIPv4(input: []const u8) !u32 {
1290 // 1. Let parts be the result of strictly splitting input on U+002E (.).1290 // 1. Let parts be the result of strictly splitting input on U+002E (.).
1291 var end = input.len;1291 var end = input.len;
1292 var parts_size = extras.countScalar(u8, input[0..end], '.') + 1;1292 var parts_size = extras.countScalar(u8, input[0..end], '.') + 1;
...@@ -1405,18 +1405,18 @@ fn shortenUrlPath(url: *ManyArrayList(15, u8), has_opaque_path: bool) void {...@@ -1405,18 +1405,18 @@ fn shortenUrlPath(url: *ManyArrayList(15, u8), has_opaque_path: bool) void {
1405//1405//
14061406
1407/// https://infra.spec.whatwg.org/#c0-control1407/// https://infra.spec.whatwg.org/#c0-control
1408fn is_c0control(c: u8) bool {1408pub fn is_c0control(c: u8) bool {
1409 if (c >= 0x00 and c <= 0x1F) return true;1409 if (c >= 0x00 and c <= 0x1F) return true;
1410 return false;1410 return false;
1411}1411}
1412/// https://infra.spec.whatwg.org/#c0-control-or-space1412/// https://infra.spec.whatwg.org/#c0-control-or-space
1413fn is_c0control_or_space(c: u8) bool {1413pub fn is_c0control_or_space(c: u8) bool {
1414 if (is_c0control(c)) return true;1414 if (is_c0control(c)) return true;
1415 if (c == ' ') return true;1415 if (c == ' ') return true;
1416 return false;1416 return false;
1417}1417}
1418/// https://url.spec.whatwg.org/#forbidden-host-code-point1418/// https://url.spec.whatwg.org/#forbidden-host-code-point
1419fn is_forbidden_host_codepoint(c: u8) bool {1419pub fn is_forbidden_host_codepoint(c: u8) bool {
1420 if (c == 0) return true;1420 if (c == 0) return true;
1421 if (c == '\t') return true;1421 if (c == '\t') return true;
1422 if (c == '\n') return true;1422 if (c == '\n') return true;
...@@ -1437,7 +1437,7 @@ fn is_forbidden_host_codepoint(c: u8) bool {...@@ -1437,7 +1437,7 @@ fn is_forbidden_host_codepoint(c: u8) bool {
1437 return false;1437 return false;
1438}1438}
1439/// https://url.spec.whatwg.org/#forbidden-domain-code-point1439/// https://url.spec.whatwg.org/#forbidden-domain-code-point
1440fn is_forbidden_domain_codepoint(c: u8) bool {1440pub fn is_forbidden_domain_codepoint(c: u8) bool {
1441 if (is_forbidden_host_codepoint(c)) return true;1441 if (is_forbidden_host_codepoint(c)) return true;
1442 if (is_c0control(c)) return true;1442 if (is_c0control(c)) return true;
1443 if (c == '%') return true;1443 if (c == '%') return true;
...@@ -1445,7 +1445,7 @@ fn is_forbidden_domain_codepoint(c: u8) bool {...@@ -1445,7 +1445,7 @@ fn is_forbidden_domain_codepoint(c: u8) bool {
1445 return false;1445 return false;
1446}1446}
1447/// https://url.spec.whatwg.org/#url-code-points1447/// https://url.spec.whatwg.org/#url-code-points
1448fn is_url_codepoint(c: u21) bool {1448pub fn is_url_codepoint(c: u21) bool {
1449 if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true;1449 if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true;
1450 if (c == '!') return true;1450 if (c == '!') return true;
1451 if (c == '$') return true;1451 if (c == '$') return true;
...@@ -1472,12 +1472,12 @@ fn is_url_codepoint(c: u21) bool {...@@ -1472,12 +1472,12 @@ fn is_url_codepoint(c: u21) bool {
1472 return false;1472 return false;
1473}1473}
1474/// https://url.spec.whatwg.org/#c0-control-percent-encode-set1474/// https://url.spec.whatwg.org/#c0-control-percent-encode-set
1475fn is_c0control_percent_char(c: u8) bool {1475pub fn is_c0control_percent_char(c: u8) bool {
1476 if (c >= 0x00 and c <= 0x1F) return true;1476 if (c >= 0x00 and c <= 0x1F) return true;
1477 return c > 0x7E;1477 return c > 0x7E;
1478}1478}
1479/// https://url.spec.whatwg.org/#query-percent-encode-set1479/// https://url.spec.whatwg.org/#query-percent-encode-set
1480fn is_query_percent_char(c: u8) bool {1480pub fn is_query_percent_char(c: u8) bool {
1481 if (c == ' ') return true;1481 if (c == ' ') return true;
1482 if (c == '"') return true;1482 if (c == '"') return true;
1483 if (c == '#') return true;1483 if (c == '#') return true;
...@@ -1486,7 +1486,7 @@ fn is_query_percent_char(c: u8) bool {...@@ -1486,7 +1486,7 @@ fn is_query_percent_char(c: u8) bool {
1486 return is_c0control_percent_char(c);1486 return is_c0control_percent_char(c);
1487}1487}
1488/// https://url.spec.whatwg.org/#path-percent-encode-set1488/// https://url.spec.whatwg.org/#path-percent-encode-set
1489fn is_path_percent_char(c: u8) bool {1489pub fn is_path_percent_char(c: u8) bool {
1490 if (c == '?') return true;1490 if (c == '?') return true;
1491 if (c == '^') return true;1491 if (c == '^') return true;
1492 if (c == '`') return true;1492 if (c == '`') return true;
...@@ -1495,12 +1495,12 @@ fn is_path_percent_char(c: u8) bool {...@@ -1495,12 +1495,12 @@ fn is_path_percent_char(c: u8) bool {
1495 return is_query_percent_char(c);1495 return is_query_percent_char(c);
1496}1496}
1497/// https://url.spec.whatwg.org/#special-query-percent-encode-set1497/// https://url.spec.whatwg.org/#special-query-percent-encode-set
1498fn is_special_query_percent_char(c: u8) bool {1498pub fn is_special_query_percent_char(c: u8) bool {
1499 if (c == '\'') return true;1499 if (c == '\'') return true;
1500 return is_query_percent_char(c);1500 return is_query_percent_char(c);
1501}1501}
1502/// https://url.spec.whatwg.org/#fragment-percent-encode-set1502/// https://url.spec.whatwg.org/#fragment-percent-encode-set
1503fn is_fragment_percent_char(c: u8) bool {1503pub fn is_fragment_percent_char(c: u8) bool {
1504 if (c == ' ') return true;1504 if (c == ' ') return true;
1505 if (c == '"') return true;1505 if (c == '"') return true;
1506 if (c == '<') return true;1506 if (c == '<') return true;
...@@ -1509,7 +1509,7 @@ fn is_fragment_percent_char(c: u8) bool {...@@ -1509,7 +1509,7 @@ fn is_fragment_percent_char(c: u8) bool {
1509 return is_c0control_percent_char(c);1509 return is_c0control_percent_char(c);
1510}1510}
1511/// https://url.spec.whatwg.org/#userinfo-percent-encode-set1511/// https://url.spec.whatwg.org/#userinfo-percent-encode-set
1512fn is_userinfo_percent_char(c: u8) bool {1512pub fn is_userinfo_percent_char(c: u8) bool {
1513 if (c == '/') return true;1513 if (c == '/') return true;
1514 if (c == ':') return true;1514 if (c == ':') return true;
1515 if (c == ';') return true;1515 if (c == ';') return true;