Repository: babel/minify (js)

Issue:
minify breaks jquery -> replaces \0 with NUL (Ascii)
Download jquery.min.js from https://code.jquery.com/jquery-3.2.1.min.js

Run Babel Minify on it.

Look at the result File and search for Ascii NUL -> you will find some

Pull request description:
Bugfix Regex's containing (\0)
fixes #732

Patch:
diff --git a/packages/babel-plugin-transform-regexp-constructors/src/index.js b/packages/babel-plugin-transform-regexp-constructors/src/index.js
index 6aa64a4..ddd35d6 100644
--- a/packages/babel-plugin-transform-regexp-constructors/src/index.js
+++ b/packages/babel-plugin-transform-regexp-constructors/src/index.js
@@ -22,6 +22,9 @@ function createRegExpLiteral(args, prettify, t) {
       .replace(/\f/g, "\\f")
       .replace(/\r/g, "\\r");
   }
+
+  pattern = pattern.replace(/\0/g, "\\0");
+
   return t.regExpLiteral(pattern, flags);
 }
 


Test patch:
diff --git a/packages/babel-plugin-transform-regexp-constructors/__tests__/transform-regexp-constructors-test.js b/packages/babel-plugin-transform-regexp-constructors/__tests__/transform-regexp-constructors-test.js
index a059a06..13295fc 100644
--- a/packages/babel-plugin-transform-regexp-constructors/__tests__/transform-regexp-constructors-test.js
+++ b/packages/babel-plugin-transform-regexp-constructors/__tests__/transform-regexp-constructors-test.js
@@ -135,4 +135,14 @@ describe("transform-regexp-constructors-plugin", () => {
     var x = /\/x\//;
   `
   );
+
+  thePlugin(
+    "should keep NUL",
+    String.raw`
+    var x = new RegExp('\0');
+  `,
+    String.raw`
+    var x = /\0/;
+  `
+  );
 });