Skip to content

Commit 58bb0a7

Browse files
author
Nick Hahn
committed
Merge branch 'bugfix/wildcard-match-zero'
2 parents 8c782d2 + cf1d4fa commit 58bb0a7

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use alloc::string::{String, ToString};
55
use alloc::vec::Vec;
66
use core::fmt::{Display, Formatter};
77
use nom::branch::alt;
8-
use nom::bytes::complete::{is_a, is_not, tag, take, take_while1, take_while_m_n};
8+
use nom::bytes::complete::{is_a, is_not, tag, take, take_while, take_while1, take_while_m_n};
99
use nom::character::complete::{char, satisfy};
1010
use nom::combinator::{all_consuming, complete, opt, recognize, verify};
1111
use nom::error::{ErrorKind, ParseError};
@@ -375,7 +375,7 @@ fn match_wildcard<'a>(
375375
});
376376
match next {
377377
// No next component, consume all allowed characters until end or next '/'
378-
None => verify(take_while1(is_address_character), |s: &str| {
378+
None => verify(take_while(is_address_character), |s: &str| {
379379
s.len() >= minimum_length
380380
})(input),
381381
// There is another element in this part, so logic gets a bit more complicated

tests/address_test.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ fn test_matcher() {
247247
.expect("Valid address pattern")
248248
));
249249

250+
matcher = Matcher::new("/oscillator/[12345]*").expect("Should be valid");
251+
assert!(matcher.match_address(
252+
&OscAddress::new(String::from("/oscillator/12")).expect("Valid address pattern")
253+
));
254+
assert!(matcher.match_address(
255+
&OscAddress::new(String::from("/oscillator/2")).expect("Valid address pattern")
256+
));
257+
assert!(!matcher.match_address(
258+
&OscAddress::new(String::from("/oscillator/6")).expect("Valid address pattern")
259+
));
260+
assert!(!matcher.match_address(
261+
&OscAddress::new(String::from("/oscillator/60")).expect("Valid address pattern")
262+
));
263+
250264
// Mix with choice
251265
matcher = Matcher::new("/oscillator/*{bar,baz}/frequency").expect("Should be valid");
252266
assert!(matcher.match_address(

0 commit comments

Comments
 (0)