Skip to content

Commit

Permalink
fix(Kernels): Allow selector tags to have hyphens
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Dec 10, 2021
1 parent dcdd1bb commit 7b447c9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rust/kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ impl KernelSelector {
/// Parse a kernel selector string into a `KernelSelector`
pub fn parse(selector: &str) -> Self {
static REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"(\b(name|lang|type)\s*:\s*(\w+)\b)|(\w+)").expect("Unable to create regex")
Regex::new(r"(\b(name|lang|type)\s*:\s*([\w-]+)\b)|([\w-]+)")
.expect("Unable to create regex")
});

let mut any = None;
Expand Down Expand Up @@ -308,9 +309,9 @@ mod test {
assert_eq!(ks.lang, Some("py".to_string()));
assert_eq!(ks.r#type, Some("jupyter".to_string()));

let ks = KernelSelector::parse("name:ir");
let ks = KernelSelector::parse("name:node-micro");
assert_eq!(ks.any, None);
assert_eq!(ks.name, Some("ir".to_string()));
assert_eq!(ks.name, Some("node-micro".to_string()));
assert_eq!(ks.lang, None);
assert_eq!(ks.r#type, None);

Expand Down

0 comments on commit 7b447c9

Please sign in to comment.