Skip to content

Commit 8b3f36c

Browse files
committed
url/location host getter
1 parent d397d75 commit 8b3f36c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/browser/URL.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn getUserInfo(raw: [:0]const u8) ?[]const u8 {
233233
return null;
234234
}
235235

236-
fn getHost(raw: [:0]const u8) []const u8 {
236+
pub fn getHost(raw: [:0]const u8) []const u8 {
237237
const scheme_end = std.mem.indexOf(u8, raw, "://") orelse return "";
238238

239239
var authority_start = scheme_end + 3;

src/browser/webapi/Location.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub fn getHostname(self: *const Location) []const u8 {
2626
return self._url.getHostname();
2727
}
2828

29+
pub fn getHost(self: *const Location) []const u8 {
30+
return self._url.getHost();
31+
}
32+
2933
pub fn getPort(self: *const Location) []const u8 {
3034
return self._url.getPort();
3135
}
@@ -61,6 +65,7 @@ pub const JsApi = struct {
6165
pub const hash = bridge.accessor(Location.getHash, null, .{});
6266
pub const pathname = bridge.accessor(Location.getPathname, null, .{});
6367
pub const hostname = bridge.accessor(Location.getHostname, null, .{});
68+
pub const host = bridge.accessor(URL.getHost, null, .{});
6469
pub const port = bridge.accessor(Location.getPort, null, .{});
6570
pub const origin = bridge.accessor(Location.getOrigin, null, .{});
6671
pub const protocol = bridge.accessor(Location.getProtocol, null, .{});

src/browser/webapi/URL.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ pub fn getHostname(self: *const URL) []const u8 {
6262
return U.getHostname(self._raw);
6363
}
6464

65+
pub fn getHost(self: *const URL) []const u8 {
66+
return U.getHost(self._raw);
67+
}
68+
6569
pub fn getPort(self: *const URL) []const u8 {
6670
return U.getPort(self._raw);
6771
}
@@ -180,6 +184,7 @@ pub const JsApi = struct {
180184
pub const username = bridge.accessor(URL.getUsername, null, .{});
181185
pub const password = bridge.accessor(URL.getPassword, null, .{});
182186
pub const hostname = bridge.accessor(URL.getHostname, null, .{});
187+
pub const host = bridge.accessor(URL.getHost, null, .{});
183188
pub const port = bridge.accessor(URL.getPort, null, .{});
184189
pub const origin = bridge.accessor(URL.getOrigin, null, .{});
185190
pub const protocol = bridge.accessor(URL.getProtocol, null, .{});

0 commit comments

Comments
 (0)