Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ret

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ret - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

9

dist/reconstruct.js

@@ -41,6 +41,7 @@ "use strict";

// Check token.remember
const prefix = token.remember ? '' :
token.followedBy ? '?=' :
token.notFollowedBy ? '?!' :
'?:';
const prefix = token.name ? `?<${token.name}>` :
token.remember ? '' :
token.followedBy ? '?=' :
token.notFollowedBy ? '?!' :
'?:';
return `(${prefix}${createAlternate(token)})`;

@@ -47,0 +48,0 @@ }

@@ -27,2 +27,11 @@ "use strict";

/**
* Valid opening characters for capture group names.
*/
const captureGroupFirstChar = /^[a-zA-Z_$]$/i;
/**
* Valid characters for capture group names.
*/
const captureGroupChars = /^[a-zA-Z0-9_$]$/i;
const digit = /\d/;
/**
* Tokenizes a regular expression (that is currently a string)

@@ -83,5 +92,5 @@ * @param {string} regexpStr String of regular expression to be tokenized

// In which case it's a reference.
if (/\d/.test(c)) {
if (digit.test(c)) {
let digits = c;
while (i < str.length && /\d/.test(str[i])) {
while (i < str.length && digit.test(str[i])) {
digits += str[i++];

@@ -141,3 +150,3 @@ }

};
// If if this is a special kind of group.
// If this is a special kind of group.
if (str[i] === '?') {

@@ -149,2 +158,3 @@ c = str[i + 1];

group.followedBy = true;
group.remember = false;
// Match if not followed by.

@@ -154,8 +164,36 @@ }

group.notFollowedBy = true;
group.remember = false;
}
else if (c !== ':') {
else if (c === '<') {
let name = '';
if (captureGroupFirstChar.test(str[i])) {
name += str[i];
i++;
}
else {
throw new SyntaxError(`Invalid regular expression: /${regexpStr}/: Invalid capture group name, character '${str[i]}'` +
` after '<' at column ${i + 1}`);
}
while (i < str.length && captureGroupChars.test(str[i])) {
name += str[i];
i++;
}
if (!name) {
throw new SyntaxError(`Invalid regular expression: /${regexpStr}/: Invalid capture group name, character '${str[i]}'` +
` after '<' at column ${i + 1}`);
}
if (str[i] !== '>') {
throw new SyntaxError(`Invalid regular expression: /${regexpStr}/: Unclosed capture group name, expected '>', found` +
` '${str[i]}' at column ${i + 1}`);
}
group.name = name;
i++;
}
else if (c === ':') {
group.remember = false;
}
else {
throw new SyntaxError(`Invalid regular expression: /${regexpStr}/: Invalid group, character '${c}'` +
` after '?' at column ${i - 1}`);
}
group.remember = false;
}

@@ -162,0 +200,0 @@ else {

@@ -20,2 +20,3 @@ import { types } from './types';

lookBehind?: boolean;
name?: string;
}>;

@@ -22,0 +23,0 @@ export declare type Set = Base<types.SET, {

@@ -11,3 +11,3 @@ {

],
"version": "0.4.3",
"version": "0.5.0",
"repository": {

@@ -14,0 +14,0 @@ "type": "git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc