Skip to content

Commit

Permalink
We need to split on byte lengths, not code point counts
Browse files Browse the repository at this point in the history
  • Loading branch information
nightkr committed Dec 26, 2021
1 parent 036d028 commit fed4850
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions kube-core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ pub enum Version {
impl Version {
fn try_parse(v: &str) -> Option<Version> {
let v = v.strip_prefix('v')?;
let major_chars = v.chars().take_while(|ch| ch.is_ascii_digit()).count();
let major = &v[..major_chars];
let major = v.split_terminator(|ch: char| !ch.is_ascii_digit()).next()?;
let v = &v[major.len()..];
let major: u32 = major.parse().ok()?;
let v = &v[major_chars..];
if v.is_empty() {
return Some(Version::Stable(major));
}
Expand Down

0 comments on commit fed4850

Please sign in to comment.