Skip to content

Commit

Permalink
Fix topic name validation (#661)
Browse files Browse the repository at this point in the history
* Fix topic name validation

* Update wording
  • Loading branch information
nicholastmosher authored Jan 10, 2021
1 parent d3cb47d commit 8499f5c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/extension-consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ futures-lite = { version = "1.7.0" }
thiserror = "1.0.20"
eyre = "0.6.1"
which = "4.0.2"

hostname-validator = "1.0.0"

# Fluvio dependencies

Expand Down
7 changes: 3 additions & 4 deletions src/extension-consumer/src/topic/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,10 @@ impl CreateTopicOpt {
})
};

let is_alphanumeric =
self.topic.is_ascii() && self.topic.chars().all(|c| c.is_alphanumeric());
if !is_alphanumeric {
let is_valid = hostname_validator::is_valid(&self.topic);
if !is_valid {
return Err(ConsumerError::InvalidArg(
"Topic name must be alphanumeric".to_string(),
"Topic name must only contain alphanumeric characters, '-', or '.'".to_string(),
));
}

Expand Down

0 comments on commit 8499f5c

Please sign in to comment.