Skip to content

Commit 5375105

Browse files
committed
nostr: RelayUrl::host function
Signed-off-by: Awiteb <[email protected]>
1 parent 1c66cfd commit 5375105

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

crates/nostr/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
- Support NIP-A0 (Voice Messages) (https://github.com/rust-nostr/nostr/pull/1032)
4949
- Add `hex` dependency (https://github.com/rust-nostr/nostr/pull/1051)
5050
- Add `nip25::ReactionTarget` (https://github.com/rust-nostr/nostr/pull/1063)
51+
- Add `RelayUrl::host` function (https://github.com/rust-nostr/nostr/pull/1066)
5152

5253
### Changed
5354

crates/nostr/src/types/url.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ impl RelayUrl {
166166
self.url.domain()
167167
}
168168

169+
/// Return the parsed representation of the host for this URL.
170+
/// Non-ASCII domain labels are punycode-encoded per IDNA if this is the host
171+
/// of a special URL, or percent encoded for non-special URLs.
172+
#[inline]
173+
pub fn host(&self) -> Option<Host<&str>> {
174+
self.url.host()
175+
}
176+
169177
/// Return the serialization of this relay URL without the trailing slash.
170178
///
171179
/// This method will always remove the trailing slash.

0 commit comments

Comments
 (0)