Skip to content

Commit

Permalink
fix: anchor the regex used for ictc (#17)
Browse files Browse the repository at this point in the history
Rust's regex crate does not have a notion of `regex.match`; it instead
just provides `regex.find` and requires that you anchor your regex
yourself,
[discussion](rust-lang/regex#737).

This is more a correctness fix than a performance fix.
  • Loading branch information
sxlijin authored Dec 8, 2022
1 parent 81aa01e commit b9538c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rules/if_change_then_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub struct IctcBlock {
}

lazy_static::lazy_static! {
static ref RE_BEGIN: Regex = Regex::new(r"(?i) *(//|#) *ifchange").unwrap();
static ref RE_END: Regex = Regex::new(r"(?i) *(//|#) *thenchange (.*)").unwrap();
static ref RE_BEGIN: Regex = Regex::new(r"(?i)^\s*(//|#)\s*ifchange\s*$").unwrap();
static ref RE_END: Regex = Regex::new(r"(?i)^\s*(//|#)\s*thenchange\s*(.*)$").unwrap();

}

Expand Down

0 comments on commit b9538c7

Please sign in to comment.