Skip to content

Commit 7ade8dd

Browse files
committed
feat: add validation functions
1 parent 51fb75d commit 7ade8dd

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/lib.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,42 @@ impl Url {
251251
let input_with_0_terminate = std::ffi::CString::new(input.as_ref()).unwrap();
252252
unsafe { ffi::ada_set_protocol(self.url, input_with_0_terminate.as_ptr()) }
253253
}
254+
255+
pub fn has_credentials(&self) -> bool {
256+
unsafe { ffi::ada_has_credentials(self.url) }
257+
}
258+
259+
pub fn has_empty_hostname(&self) -> bool {
260+
unsafe { ffi::ada_has_empty_hostname(self.url) }
261+
}
262+
263+
pub fn has_hostname(&self) -> bool {
264+
unsafe { ffi::ada_has_hostname(self.url) }
265+
}
266+
267+
pub fn has_non_empty_username(&self) -> bool {
268+
unsafe { ffi::ada_has_non_empty_username(self.url) }
269+
}
270+
271+
pub fn has_non_empty_password(&self) -> bool {
272+
unsafe { ffi::ada_has_non_empty_password(self.url) }
273+
}
274+
275+
pub fn has_port(&self) -> bool {
276+
unsafe { ffi::ada_has_port(self.url) }
277+
}
278+
279+
pub fn has_password(&self) -> bool {
280+
unsafe { ffi::ada_has_password(self.url) }
281+
}
282+
283+
pub fn has_hash(&self) -> bool {
284+
unsafe { ffi::ada_has_hash(self.url) }
285+
}
286+
287+
pub fn has_search(&self) -> bool {
288+
unsafe { ffi::ada_has_search(self.url) }
289+
}
254290
}
255291

256292
#[cfg(test)]
@@ -293,6 +329,13 @@ mod test {
293329

294330
out.set_protocol("wss");
295331
assert_eq!(out.protocol(), "wss:");
332+
333+
assert!(out.has_credentials());
334+
assert!(out.has_non_empty_username());
335+
assert!(out.has_non_empty_password());
336+
assert!(out.has_search());
337+
assert!(out.has_hash());
338+
assert!(out.has_password());
296339
}
297340

298341
#[test]

0 commit comments

Comments
 (0)