aboutsummaryrefslogtreecommitdiff
path: root/src/query_string_map.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/query_string_map.zig')
-rw-r--r--src/query_string_map.zig23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/query_string_map.zig b/src/query_string_map.zig
index e9e1f2e6d..1bac8f5ce 100644
--- a/src/query_string_map.zig
+++ b/src/query_string_map.zig
@@ -18,9 +18,30 @@ pub const URL = struct {
search: string = "",
searchParams: ?QueryStringMap = null,
username: string = "",
-
port_was_automatically_set: bool = false,
+ pub fn displayProtocol(this: *const URL) string {
+ if (this.protocol.len > 0) {
+ return this.protocol;
+ }
+
+ if (this.getPort()) |port| {
+ if (port == 443) {
+ return "https";
+ }
+ }
+
+ return "http";
+ }
+
+ pub fn displayHostname(this: *const URL) string {
+ if (this.hostname.len > 0) {
+ return this.hostname;
+ }
+
+ return "localhost";
+ }
+
pub fn hasHTTPLikeProtocol(this: *const URL) bool {
return strings.eqlComptime(this.protocol, "http") or strings.eqlComptime(this.protocol, "https");
}