Skip to content

Commit

Permalink
fix: handle multi-byte chars on redacted transformer (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepoviola authored Aug 20, 2023
1 parent 15ba775 commit 1476dd7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion replibyte/src/transformer/redacted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Transformer for RedactedTransformer {
len if len > 3 => {
format!(
"{}{}",
&value[0..3],
value.chars().take(3).collect::<String>(),
self.options
.character
.to_string()
Expand Down Expand Up @@ -118,6 +118,18 @@ mod tests {
assert_eq!(transformed_value.to_owned(), "424**********")
}

#[test]
fn redact_with_multi_byte_char() {
let transformer = get_transformer();
let column = Column::StringValue(
"multi_byte_column".to_string(),
"🦀ë池cd".to_string(),
);
let transformed_column = transformer.transform(column);
let transformed_value = transformed_column.string_value().unwrap();
assert_eq!(transformed_value.to_owned(), "🦀ë池**********")
}

#[test]
fn strings_lower_than_3_chars_remains_visible() {
let transformer = get_transformer();
Expand Down

0 comments on commit 1476dd7

Please sign in to comment.