chore: Trim the strings in repo announce command
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -29,7 +29,7 @@ use nostr::{
|
||||
use crate::{
|
||||
cli::{CliOptions, CommandRunner},
|
||||
error::N34Result,
|
||||
nostr_utils::{NostrClient, traits::NewGitRepositoryAnnouncement},
|
||||
nostr_utils::{NostrClient, traits::NewGitRepositoryAnnouncement, utils},
|
||||
};
|
||||
|
||||
|
||||
@@ -83,13 +83,13 @@ impl CommandRunner for AnnounceArgs {
|
||||
|
||||
let event = EventBuilder::new_git_repo(
|
||||
self.repo_id,
|
||||
self.name,
|
||||
self.description,
|
||||
self.name.map(utils::str_trim),
|
||||
self.description.map(utils::str_trim),
|
||||
self.web,
|
||||
self.clone,
|
||||
options.relays,
|
||||
maintainers,
|
||||
self.labels,
|
||||
self.labels.into_iter().map(utils::str_trim).collect(),
|
||||
)?
|
||||
.build(user_pubk);
|
||||
let nevent = Nip19Event::new(event.id.expect("There is an id"))
|
||||
|
||||
@@ -72,6 +72,7 @@ impl EventBuilder {
|
||||
maintainers: Vec<PublicKey>,
|
||||
labels: Vec<String>,
|
||||
) -> N34Result<EventBuilder> {
|
||||
let repo_id = repo_id.trim();
|
||||
if repo_id.is_empty() || repo_id != repo_id.to_case(Case::Kebab) {
|
||||
return Err(N34Error::InvalidRepoId);
|
||||
}
|
||||
|
||||
@@ -75,3 +75,8 @@ pub fn event_into_repo(event: Event, repo_id: impl Into<String>) -> GitRepositor
|
||||
maintainers: tags.dmap_tag(TagKind::Maintainers, tag_values),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a new string with leading and trailing whitespace removed.
|
||||
pub fn str_trim(s: String) -> String {
|
||||
s.trim().to_owned()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user