pijul_org / pijul

Removing all escape codes in descriptions

By blabla on April 25, 2019
This patch is not signed.
9wegoEApuDNMSnMFw4Tfxn4XjkxkRvnyJcEEeFz11VCzk4gDUp18uF5qLDhrWt9pcJKeAwavDRfnm7wdLUZN49PB
This patch is in the following branches:
latest
master
testing
60
61


62
63
64
65
66


fn remove_escape_codes(f: &str) -> std::borrow::Cow<str> {
    lazy_static! {
        static ref RE: Regex = Regex::new("\x1b\\[[0-9;]*[a-zA-Z]").unwrap();
    if f.as_bytes().contains(&27) {
        std::borrow::Cow::Owned(f.chars().filter(|&c| c != 27 as char).collect())
    } else {
        std::borrow::Cow::Borrowed(f)
    }
    RE.replace_all(f, "")
58
59

clap = "2.32"
regex = "1.1"
lazy_static = "1.3"
25
26

extern crate toml;
extern crate username;
#[macro_use] extern crate lazy_static;