Skip to content

Commit 51c3c4e

Browse files
authored
Fix for issue 1808 (#1811)
1 parent a44b52e commit 51c3c4e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl<'a> Input for &'a str {
462462
let (str1, str2) = self.split_at(i);
463463
Ok((str2, str1))
464464
}
465-
None => Ok(self.split_at(0)),
465+
None => Ok(self.take_split(self.input_len())),
466466
}
467467
}
468468

tests/issues.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,15 @@ fn issue_1586_parser_iterator_impl() {
269269

270270
assert_eq!(parse_input("123\n456").collect::<Vec<_>>(), vec![123, 456]);
271271
}
272+
273+
#[test]
274+
fn issue_1808_complete_string_parser_returns_wrong_slice() {
275+
use nom::character::complete::multispace0;
276+
use nom::combinator::recognize;
277+
278+
let input = "\n";
279+
assert_eq!(
280+
recognize::<_, nom::error::Error<_>, _>(multispace0).parse(input),
281+
Ok(("", "\n"))
282+
);
283+
}

0 commit comments

Comments
 (0)