aboutsummaryrefslogtreecommitdiff
path: root/node_modules/regenerate
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/regenerate')
-rw-r--r--node_modules/regenerate/package.json2
-rw-r--r--node_modules/regenerate/regenerate.js16
2 files changed, 13 insertions, 5 deletions
diff --git a/node_modules/regenerate/package.json b/node_modules/regenerate/package.json
index 5c1a6a6e9..860f3445c 100644
--- a/node_modules/regenerate/package.json
+++ b/node_modules/regenerate/package.json
@@ -1,6 +1,6 @@
{
"name": "regenerate",
- "version": "1.3.3",
+ "version": "1.4.0",
"description": "Generate JavaScript-compatible regular expressions based on a given set of Unicode symbols or code points.",
"homepage": "https://mths.be/regenerate",
"main": "regenerate.js",
diff --git a/node_modules/regenerate/regenerate.js b/node_modules/regenerate/regenerate.js
index fb849c5eb..8bca8a077 100644
--- a/node_modules/regenerate/regenerate.js
+++ b/node_modules/regenerate/regenerate.js
@@ -533,13 +533,21 @@
else if (codePoint == 0x0D) {
string = '\\r';
}
+ else if (codePoint == 0x2D) {
+ // https://mathiasbynens.be/notes/javascript-escapes#hexadecimal
+ // Note: `-` (U+002D HYPHEN-MINUS) is escaped in this way rather
+ // than by backslash-escaping, in case the output is used outside
+ // of a character class in a `u` RegExp. /\-/u throws, but
+ // /\x2D/u is fine.
+ string = '\\x2D';
+ }
else if (codePoint == 0x5C) {
string = '\\\\';
}
else if (
codePoint == 0x24 ||
(codePoint >= 0x28 && codePoint <= 0x2B) ||
- (codePoint >= 0x2D && codePoint <= 0x2F) ||
+ codePoint == 0x2E || codePoint == 0x2F ||
codePoint == 0x3F ||
(codePoint >= 0x5B && codePoint <= 0x5E) ||
(codePoint >= 0x7B && codePoint <= 0x7D)
@@ -547,9 +555,10 @@
// The code point maps to an unsafe printable ASCII character;
// backslash-escape it. Here’s the list of those symbols:
//
- // $()*+-./?[\]^{|}
+ // $()*+./?[\]^{|}
//
- // See #7 for more info.
+ // This matches SyntaxCharacters as well as `/` (U+002F SOLIDUS).
+ // https://tc39.github.io/ecma262/#prod-SyntaxCharacter
string = '\\' + stringFromCharCode(codePoint);
}
else if (codePoint >= 0x20 && codePoint <= 0x7E) {
@@ -563,7 +572,6 @@
string = stringFromCharCode(codePoint);
}
else if (codePoint <= 0xFF) {
- // https://mathiasbynens.be/notes/javascript-escapes#hexadecimal
string = '\\x' + pad(hex(codePoint), 2);
}
else { // `codePoint <= 0xFFFF` holds true.