mirror of
https://github.com/bspeice/dtparse
synced 2024-12-22 04:18: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 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))?;
|
ymd.append(value as i32, &tokens[idx + 4], Some(YMDLabel::Month))?;
|
||||||
} else if let Ok(val) = tokens[idx + 4].parse::<i32>() {
|
} else if let Ok(val) = tokens[idx + 4].parse::<i32>() {
|
||||||
ymd.append(val, &tokens[idx + 4], None)?;
|
ymd.append(val, &tokens[idx + 4], None)?;
|
||||||
|
@ -97,3 +97,10 @@ fn github_36() {
|
|||||||
let parse_result = parse(parse_str);
|
let parse_result = parse(parse_str);
|
||||||
assert!(parse_result.is_err());
|
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