Socket
Socket
Sign inDemoInstall

regexpu-core

Package Overview
Dependencies
10
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.0 to 3.3.0

README.md

2

package.json
{
"name": "regexpu-core",
"version": "3.2.0",
"version": "3.3.0",
"description": "regexpu’s core functionality (i.e. `rewritePattern(pattern, flag)`), capable of translating ES6 Unicode regular expressions to ES5.",

@@ -5,0 +5,0 @@ "homepage": "https://mths.be/regexpu",

@@ -11,5 +11,27 @@ 'use strict';

const getCharacterClassEscapeSet = function(character) {
if (config.unicode) {
if (config.ignoreCase) {
// Prepare a Regenerate set containing all code points, used for negative
// character classes (if any).
const UNICODE_SET = regenerate().addRange(0x0, 0x10FFFF);
// Without the `u` flag, the range stops at 0xFFFF.
// https://mths.be/es6#sec-pattern-semantics
const BMP_SET = regenerate().addRange(0x0, 0xFFFF);
// Prepare a Regenerate set containing all code points that are supposed to be
// matched by `/./u`. https://mths.be/es6#sec-atom
const DOT_SET_UNICODE = UNICODE_SET.clone() // all Unicode code points
.remove(
// minus `LineTerminator`s (https://mths.be/es6#sec-line-terminators):
0x000A, // Line Feed <LF>
0x000D, // Carriage Return <CR>
0x2028, // Line Separator <LS>
0x2029 // Paragraph Separator <PS>
);
// Prepare a Regenerate set containing all code points that are supposed to be
// matched by `/./` (only BMP code points).
const DOT_SET = DOT_SET_UNICODE.clone()
.intersection(BMP_SET);
const getCharacterClassEscapeSet = function(character, unicode, ignoreCase) {
if (unicode) {
if (ignoreCase) {
return ESCAPE_SETS.UNICODE_IGNORE_CASE.get(character);

@@ -22,2 +44,9 @@ }

const getDotSet = function(unicode, dotAll) {
if (dotAll) {
return unicode ? UNICODE_SET : BMP_SET;
}
return unicode ? DOT_SET_UNICODE : DOT_SET;
};
const getUnicodePropertyValueSet = function(property, value) {

@@ -69,24 +98,2 @@ const path = value ?

// Prepare a Regenerate set containing all code points, used for negative
// character classes (if any).
const UNICODE_SET = regenerate().addRange(0x0, 0x10FFFF);
// Without the `u` flag, the range stops at 0xFFFF.
// https://mths.be/es6#sec-pattern-semantics
const BMP_SET = regenerate().addRange(0x0, 0xFFFF);
// Prepare a Regenerate set containing all code points that are supposed to be
// matched by `/./u`. https://mths.be/es6#sec-atom
const DOT_SET_UNICODE = UNICODE_SET.clone() // all Unicode code points
.remove(
// minus `LineTerminator`s (https://mths.be/es6#sec-line-terminators):
0x000A, // Line Feed <LF>
0x000D, // Carriage Return <CR>
0x2028, // Line Separator <LS>
0x2029 // Paragraph Separator <PS>
);
// Prepare a Regenerate set containing all code points that are supposed to be
// matched by `/./` (only BMP code points).
const DOT_SET = DOT_SET_UNICODE.clone()
.intersection(BMP_SET);
// Given a range of code points, add any case-folded code points in that range

@@ -156,3 +163,7 @@ // to a set.

case 'characterClassEscape':
set.add(getCharacterClassEscapeSet(item.value));
set.add(getCharacterClassEscapeSet(
item.value,
config.unicode,
config.ignoreCase
));
break;

@@ -181,4 +192,3 @@ case 'unicodePropertyEscape':

item,
(config.unicode ? DOT_SET_UNICODE : DOT_SET)
.toString(regenerateOptions)
getDotSet(config.unicode, config.dotAll).toString(regenerateOptions)
);

@@ -199,3 +209,7 @@ break;

item,
getCharacterClassEscapeSet(item.value).toString(regenerateOptions)
getCharacterClassEscapeSet(
item.value,
config.unicode,
config.ignoreCase
).toString(regenerateOptions)
);

@@ -207,3 +221,5 @@ break;

case 'quantifier':
item.body = item.body.map(processTerm);
item.body = item.body.map(function(term) {
return processTerm(term, regenerateOptions);
});
break;

@@ -239,2 +255,3 @@ case 'value':

'unicode': false,
'dotAll': false,
'useUnicodeFlag': false

@@ -246,9 +263,12 @@ };

};
config.ignoreCase = flags && flags.includes('i');
config.unicode = flags && flags.includes('u');
const supportDotAllFlag = options && options.dotAllFlag;
config.dotAll = supportDotAllFlag && flags && flags.includes('s');
config.useUnicodeFlag = options && options.useUnicodeFlag;
const regenerateOptions = {
'hasUnicodeFlag': config.useUnicodeFlag
'hasUnicodeFlag': config.useUnicodeFlag,
'bmpOnly': !config.unicode
};
const tree = parse(pattern, flags, regjsparserFeatures);
config.ignoreCase = flags && flags.includes('i');
config.unicode = flags && flags.includes('u');
Object.assign(tree, processTerm(tree, regenerateOptions));

@@ -255,0 +275,0 @@ return generate(tree);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc