mirror of
https://github.com/bspeice/dtparse
synced 2024-11-12 17:08:09 -05:00
#45: Fix index issue
This commit is contained in:
parent
61d2aa60c6
commit
c3d6730e9c
@ -1132,7 +1132,9 @@ impl Parser {
|
||||
}
|
||||
|
||||
if idx + 3 < len_l && &tokens[idx + 3] == sep {
|
||||
if let Some(value) = info.month_index(&tokens[idx + 4]) {
|
||||
if tokens.len() <= idx + 4 {
|
||||
return Err(ParseError::UnrecognizedFormat);
|
||||
} else if let Some(value) = info.month_index(&tokens[idx + 4]) {
|
||||
ymd.append(value as i32, &tokens[idx + 4], Some(YMDLabel::Month))?;
|
||||
} else if let Ok(val) = tokens[idx + 4].parse::<i32>() {
|
||||
ymd.append(val, &tokens[idx + 4], None)?;
|
||||
|
@ -96,4 +96,11 @@ fn github_36() {
|
||||
let parse_str = str::from_utf8(&parse_vec).unwrap();
|
||||
let parse_result = parse(parse_str);
|
||||
assert!(parse_result.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn github_45() {
|
||||
assert!(parse("/2018-fifa-").is_err());
|
||||
assert!(parse("/2009/07/").is_err());
|
||||
assert!(parse("2021-09-").is_err());
|
||||
}
|
Loading…
Reference in New Issue
Block a user