diff --git a/pages/Cargo.toml b/pages/Cargo.toml index 9faf02b..ad75a99 100644 --- a/pages/Cargo.toml +++ b/pages/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -rustrict = { path = "..", features = ["trace_full", "width"] } +rustrict = { path = "..", features = ["trace_full", "width", "pii"] } yew = { version = "0.21", features = ["csr"] } [dependencies.web-sys] diff --git a/pages/src/main.rs b/pages/src/main.rs index d51c229..16454ee 100644 --- a/pages/src/main.rs +++ b/pages/src/main.rs @@ -1,12 +1,13 @@ use web_sys::{HtmlInputElement, window, InputEvent, HtmlTextAreaElement, wasm_bindgen::JsCast}; use yew::{html, Html, Callback, function_component, TargetCast}; -use rustrict::Censor; +use rustrict::{Censor, censor_and_analyze_pii}; #[function_component(App)] fn app() -> Html { let oninput = Callback::from(move |event: InputEvent| { if let Some(input) = event.target_dyn_into::() { let uncensored = input.value(); + let (uncensored, pii) = censor_and_analyze_pii(&uncensored); let analysis_element = window().unwrap().document().unwrap().get_element_by_id("analysis").unwrap(); let censored_element = window().unwrap().document().unwrap().get_element_by_id("censored").unwrap().dyn_into::().unwrap(); if uncensored.is_empty() { @@ -18,7 +19,7 @@ fn app() -> Html { let count = censor.total_matches(); let detections = censor.detections(); let width = rustrict::width_str(&uncensored); - let result = format!("{analysis:?} (width = {width}, count = {count}, detections = {detections:?})"); + let result = format!("{analysis:?} (width={width}, count={count}, detections={detections:?}, pii={pii:?})"); analysis_element.set_inner_html(&result); censored_element.set_value(&censored); }