diff options
author | 2021-08-29 21:48:14 -0700 | |
---|---|---|
committer | 2021-08-29 21:48:14 -0700 | |
commit | bd9f137b1bfb5bc3b215515ff9305e70a638daf9 (patch) | |
tree | e2a252e2b2478b6b1fb7cd23eb90e4da9c5bc8cd /src/query_string_map.zig | |
parent | 34792c15f188d0c480d64022a9d3a67a89497c70 (diff) | |
download | bun-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.zig | 23 |
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"); } |