New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

string-matching

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-matching - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

package.json
{
"name": "string-matching",
"version": "1.1.0",
"version": "1.2.0",
"description": "Checks strings against patterns and collects matched substrings",

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

@@ -34,3 +34,3 @@ const smp = require('./string_matching_parser')

var _match = (steps, received, dict) => {
var _match = (steps, received, dict, throw_matching_errors) => {
if(typeof received != 'string') throw new Error('Received element is not string')

@@ -45,3 +45,7 @@

if(remainder.substr(0, step.str.length) != step.str){
throw new Error("Expected substr '" + step.str + "' not found")
if(throw_matching_errors) {
throw new Error("Expected substr '" + step.str + "' not found")
} else {
return false
}
}

@@ -61,4 +65,8 @@ remainder = remainder.slice(step.str.length)

if(pos < 0) {
// we dont use (pos <= 0) because it is OK to collect empty strings
throw new Error("Expected string collection delimiter '" + next_step.str + "' not found")
if(throw_matching_errors) {
// we dont use (pos <= 0) because it is OK to collect empty strings
throw new Error("Expected string collection delimiter '" + next_step.str + "' not found")
} else {
return false
}
}

@@ -74,4 +82,8 @@ collected_str = remainder.substring(0, pos)

_set_key(step, collected_str, dict)
} else {
} else {
if(throw_matching_errors) {
throw new Error("Invalid match step")
} else {
return false
}
}

@@ -82,3 +94,3 @@ }

var gen_matcher = (expected) => {
var gen_matcher = (expected, throw_matching_errors) => {
var steps

@@ -92,3 +104,3 @@ try {

return (received, dict) => {
return _match(steps, received, dict)
return _match(steps, received, dict, throw_matching_errors)
}

@@ -95,0 +107,0 @@ }

@@ -7,3 +7,3 @@ const sm = require('../src/index');

var matcher = sm.gen_matcher(`"${alias}" <${proto}:!{user}@!{ip}:!{port:num};tag=!{tag:str:30};phone=!{phone:str:10}>`)
var matcher = sm.gen_matcher(`"${alias}" <${proto}:!{user}@!{ip}:!{port:num};tag=!{tag:str:30};phone=!{phone:str:10}>`, false)

@@ -10,0 +10,0 @@ var user = 'tomjones'

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