Skip to content

Commit 7dd5ee0

Browse files
committed
various changes in ada-url module
1 parent eda77d1 commit 7dd5ee0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

vendor/ada/root.zig

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub inline fn freeOwnedString(owned: OwnedString) void {
4646
return c.ada_free_owned_string(owned);
4747
}
4848

49-
/// Returns true if given URL is valid (not NULL).
49+
/// Returns true if given URL is valid.
5050
pub inline fn isValid(url: URL) bool {
5151
return c.ada_is_valid(url);
5252
}
@@ -63,10 +63,8 @@ pub inline fn getOrigin(url: URL) []const u8 {
6363
return origin.data[0..origin.length];
6464
}
6565

66-
/// Can return an empty string.
67-
pub inline fn getHref(url: URL) []const u8 {
68-
const href = c.ada_get_href(url);
69-
return href.data[0..href.length];
66+
pub inline fn getHrefNullable(url: URL) String {
67+
return c.ada_get_href(url);
7068
}
7169

7270
/// Can return an empty string.
@@ -123,6 +121,10 @@ pub inline fn getHostname(url: URL) []const u8 {
123121
return hostname.data[0..hostname.length];
124122
}
125123

124+
pub inline fn getHostnameNullable(url: URL) String {
125+
return c.ada_get_hostname(url);
126+
}
127+
126128
pub inline fn getPathnameNullable(url: URL) String {
127129
return c.ada_get_pathname(url);
128130
}
@@ -141,6 +143,8 @@ pub inline fn getProtocol(url: URL) []const u8 {
141143
return protocol.data[0..protocol.length];
142144
}
143145

146+
/// Sets the href for given URL.
147+
/// Call `isInvalid` afterwards to check correctness.
144148
pub inline fn setHref(url: URL, input: []const u8) bool {
145149
return c.ada_set_href(url, input.ptr, input.len);
146150
}

0 commit comments

Comments
 (0)