Skip to content

Commit

Permalink
chore: stop using unicode in regexps and fix block one
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelmmiguel committed Oct 17, 2023
1 parent b8877c3 commit 09b9a16
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kits/javascript/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ enum JSWorkerType {
/// Identify the worker source code to run it properly.
fn identify_type(src: &str) -> JSWorkerType {
// Detect default exported functions and objects
let default_regex = Regex::new(r"export\s+default\s+\w+;?").unwrap();
let default_regex = Regex::new(r"(?-u)export\s+default\s+\w+;?").unwrap();
// Detect default exported object
let default_block_regex = Regex::new(r"export\s+default\s*\{(\s.+)*\};?").unwrap();
let default_block_regex = Regex::new(r"(?-u)export\s+default\s*\{(\s.*)*\};?").unwrap();
// Detect exported functions with the "as" syntax like "export { app as default }";
let default_as_regex = Regex::new(r"export\s*\{\s*\w+\s+(as default){1}\s*\};?").unwrap();
let default_as_regex = Regex::new(r"(?-u)export\s*\{\s*\w+\s+(as default){1}\s*\};?").unwrap();

if default_regex.is_match(src)
|| default_block_regex.is_match(src)
Expand Down

0 comments on commit 09b9a16

Please sign in to comment.