Skip to content

Commit

Permalink
fix(transformer): RegExp transform do not transform invalid regexps (#…
Browse files Browse the repository at this point in the history
…5494)

Treat invalid regexps the same regardless of whether they have unsupported flags or not - don't transform them.
  • Loading branch information
overlookmotel committed Sep 5, 2024
1 parent dd19823 commit 8f9627d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/oxc_transformer/src/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ impl<'a> Traverse<'a> for RegExp<'a> {
}

let pattern_source: Cow<'_, str> = match &regexp.regex.pattern {
RegExpPattern::Raw(raw) | RegExpPattern::Invalid(raw) => Cow::Borrowed(raw),
RegExpPattern::Raw(raw) => Cow::Borrowed(raw),
RegExpPattern::Pattern(p) => Cow::Owned(p.to_string()),
RegExpPattern::Invalid(_) => return,
};

let callee = {
Expand Down

0 comments on commit 8f9627d

Please sign in to comment.