aboutsummaryrefslogtreecommitdiff
path: root/src/query_string_map.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-29 21:48:14 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-29 21:48:14 -0700
commitbd9f137b1bfb5bc3b215515ff9305e70a638daf9 (patch)
treee2a252e2b2478b6b1fb7cd23eb90e4da9c5bc8cd /src/query_string_map.zig
parent34792c15f188d0c480d64022a9d3a67a89497c70 (diff)
downloadbun-bd9f137b1bfb5bc3b215515ff9305e70a638daf9.tar.gz
bun-bd9f137b1bfb5bc3b215515ff9305e70a638daf9.tar.zst
bun-bd9f137b1bfb5bc3b215515ff9305e70a638daf9.zip
latest
Former-commit-id: 096ec1222ad723d006b0151f10cb0c1b95e2bfd3
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");
}