Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leaysgur committed Aug 23, 2024
1 parent 4ea1a43 commit 763a0e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/oxc_regular_expression/examples/parse_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ fn main() {
.filter(|ident| ident.name == "RegExp")
.is_some() =>
{
println!(r"🍀 {}", new_expr.span.source_text(&source_text));
println!("🍀 {}", new_expr.span.source_text(&source_text));

let pattern = match new_expr.arguments.first() {
Some(ast::Argument::StringLiteral(sl)) => &sl.value,
Some(ast::Argument::TemplateLiteral(tl)) if tl.expressions.is_empty() => {
Some(ast::Argument::TemplateLiteral(tl))
if tl.is_no_substitution_template() =>
{
&tl.quasi().unwrap()
}
_ => {
Expand All @@ -82,7 +84,9 @@ fn main() {

let flags = match new_expr.arguments.get(1) {
Some(ast::Argument::StringLiteral(sl)) => &sl.value,
Some(ast::Argument::TemplateLiteral(tl)) if tl.expressions.is_empty() => {
Some(ast::Argument::TemplateLiteral(tl))
if tl.is_no_substitution_template() =>
{
&tl.quasi().unwrap()
}
_ => "",
Expand Down

0 comments on commit 763a0e8

Please sign in to comment.