Socket
Socket
Sign inDemoInstall

glob-to-regexp

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.4.0

5

index.js

@@ -39,3 +39,2 @@ module.exports = function (glob, opts) {

switch (c) {
case "\\":
case "/":

@@ -111,7 +110,7 @@ case "$":

// it's a globstar, so match zero or more path segments
reStr += "(?:[^/]*(?:\/|$))*";
reStr += "((?:[^/]*(?:\/|$))*)";
i++; // move over the "/"
} else {
// it's not a globstar, so only match one path segment
reStr += "[^/]*";
reStr += "([^/]*)";
}

@@ -118,0 +117,0 @@ }

2

package.json
{
"name": "glob-to-regexp",
"version": "0.3.0",
"version": "0.4.0",
"description": "Convert globs to regular expressions",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -50,5 +50,9 @@ var globToRegexp = require("./index.js");

var testStr = "\\/$^+?.()=!|{},[].*"
assertMatch(testStr, testStr);
assertMatch(testStr, testStr, { flags: 'g' });
// Test string "\\\\/$^+?.()=!|{},[].*" represents <glob>\\/$^+?.()=!|{},[].*</glob>
// The equivalent regex is: /^\\\/\$\^\+\?\.\(\)\=\!\|\{\}\,\[\]\..*$/
// Both glob and regex match: \/$^+?.()=!|{},[].*
var testStr = "\\\\/$^+?.()=!|{},[].*";
var targetStr = "\\/$^+?.()=!|{},[].*";
assertMatch(testStr, targetStr);
assertMatch(testStr, targetStr, { flags: 'g' });

@@ -158,5 +162,9 @@ // Equivalent matches without/with using RegExp 'g'

// Remaining special chars should still match themselves
var testExtStr = "\\/$^+.()=!|,.*"
assertMatch(testExtStr, testExtStr, { extended: true });
assertMatch(testExtStr, testExtStr, { extended: true, globstar: globstar, flags: 'g' });
// Test string "\\\\/$^+.()=!|,.*" represents <glob>\\/$^+.()=!|,.*</glob>
// The equivalent regex is: /^\\\/\$\^\+\.\(\)\=\!\|\,\..*$/
// Both glob and regex match: \/$^+.()=!|,.*
var testExtStr = "\\\\/$^+.()=!|,.*";
var targetExtStr = "\\/$^+.()=!|,.*";
assertMatch(testExtStr, targetExtStr, { extended: true });
assertMatch(testExtStr, targetExtStr, { extended: true, globstar: globstar, flags: 'g' });
}

@@ -163,0 +171,0 @@

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