Skip to content

Commit

Permalink
refactor: better regex expression
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Jul 1, 2024
1 parent b4ee69d commit 081ba38
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tokio-console/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,8 @@ fn truncate_registry_path(s: String) -> String {

static REGEX: OnceCell<Regex> = OnceCell::new();
let regex = REGEX.get_or_init(|| {
Regex::new(
r".*(/|\\)\.cargo(/|\\)(registry(/|\\)src(/|\\)[^/\\]*(/|\\)|git(/|\\)checkouts(/|\\))",
)
.expect("failed to compile regex")
Regex::new(r".*[/\\]\.cargo[/\\](registry[/\\]src[/\\][^/\\]*[/\\]|git[/\\]checkouts[/\\])")
.expect("failed to compile regex")
});

let s = match regex.replace(&s, "<cargo>/") {
Expand Down

0 comments on commit 081ba38

Please sign in to comment.