Skip to content

Commit

Permalink
Merge clap-rs#2989
Browse files Browse the repository at this point in the history
2989: fix: Allow unicode aware case insensitivity r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
  • Loading branch information
bors[bot] and epage committed Nov 4, 2021
2 parents 879dd23 + 4b00486 commit 4dfa56a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/parse/matches/matched_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
slice::Iter,
};

use crate::util::eq_ignore_case;
use crate::INTERNAL_ERROR_MSG;

// TODO: Maybe make this public?
Expand Down Expand Up @@ -127,7 +128,8 @@ impl MatchedArg {
pub(crate) fn contains_val(&self, val: &str) -> bool {
self.vals_flatten().any(|v| {
if self.case_insensitive {
v.eq_ignore_ascii_case(val)
// If `v` isn't utf8, it can't match `val`, so `OsStr::to_str` should be fine
v.to_str().map_or(false, |v| eq_ignore_case(v, val))
} else {
OsString::as_os_str(v) == OsStr::new(val)
}
Expand Down

0 comments on commit 4dfa56a

Please sign in to comment.