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
10501050}
10511051
10521052/// https://url.spec.whatwg.org/#concept-ipv6-parser
1053fn parseIPv6(input: []const u8) !u128 {
1053pub fn parseIPv6(input: []const u8) !u128 {
10541054 // 1. Let address be a new IPv6 address whose pieces are all 0.
10551055 var address: [8]u16 = @splat(0);
10561056 _ = &address;
......@@ -1286,7 +1286,7 @@ fn endsInANumber(input: []const u8) bool {
12861286}
12871287
12881288/// https://url.spec.whatwg.org/#concept-ipv4-parser
1289fn parseIPv4(input: []const u8) !u32 {
1289pub fn parseIPv4(input: []const u8) !u32 {
12901290 // 1. Let parts be the result of strictly splitting input on U+002E (.).
12911291 var end = input.len;
12921292 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 {
14051405//
14061406
14071407/// https://infra.spec.whatwg.org/#c0-control
1408fn is_c0control(c: u8) bool {
1408pub fn is_c0control(c: u8) bool {
14091409 if (c >= 0x00 and c <= 0x1F) return true;
14101410 return false;
14111411}
14121412/// 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 {
14141414 if (is_c0control(c)) return true;
14151415 if (c == ' ') return true;
14161416 return false;
14171417}
14181418/// 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 {
14201420 if (c == 0) return true;
14211421 if (c == '\t') return true;
14221422 if (c == '\n') return true;
......@@ -1437,7 +1437,7 @@ fn is_forbidden_host_codepoint(c: u8) bool {
14371437 return false;
14381438}
14391439/// 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 {
14411441 if (is_forbidden_host_codepoint(c)) return true;
14421442 if (is_c0control(c)) return true;
14431443 if (c == '%') return true;
......@@ -1445,7 +1445,7 @@ fn is_forbidden_domain_codepoint(c: u8) bool {
14451445 return false;
14461446}
14471447/// https://url.spec.whatwg.org/#url-code-points
1448fn is_url_codepoint(c: u21) bool {
1448pub fn is_url_codepoint(c: u21) bool {
14491449 if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true;
14501450 if (c == '!') return true;
14511451 if (c == '$') return true;
......@@ -1472,12 +1472,12 @@ fn is_url_codepoint(c: u21) bool {
14721472 return false;
14731473}
14741474/// 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 {
14761476 if (c >= 0x00 and c <= 0x1F) return true;
14771477 return c > 0x7E;
14781478}
14791479/// 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 {
14811481 if (c == ' ') return true;
14821482 if (c == '"') return true;
14831483 if (c == '#') return true;
......@@ -1486,7 +1486,7 @@ fn is_query_percent_char(c: u8) bool {
14861486 return is_c0control_percent_char(c);
14871487}
14881488/// 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 {
14901490 if (c == '?') return true;
14911491 if (c == '^') return true;
14921492 if (c == '`') return true;
......@@ -1495,12 +1495,12 @@ fn is_path_percent_char(c: u8) bool {
14951495 return is_query_percent_char(c);
14961496}
14971497/// 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 {
14991499 if (c == '\'') return true;
15001500 return is_query_percent_char(c);
15011501}
15021502/// 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 {
15041504 if (c == ' ') return true;
15051505 if (c == '"') return true;
15061506 if (c == '<') return true;
......@@ -1509,7 +1509,7 @@ fn is_fragment_percent_char(c: u8) bool {
15091509 return is_c0control_percent_char(c);
15101510}
15111511/// 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 {
15131513 if (c == '/') return true;
15141514 if (c == ':') return true;
15151515 if (c == ';') return true;