From 0a7c0587a9b753ab85f463c230d2b3e6bd8c03c6 Mon Sep 17 00:00:00 2001 From: Dan Motzenbecker Date: Sat, 3 Sep 2016 16:36:31 -0400 Subject: [PATCH] fix for non-global regular expressions --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 276556b..55b0886 100644 --- a/index.js +++ b/index.js @@ -44,6 +44,9 @@ StreamSnitch.prototype._write = function(chunk, encoding, cb) { while (match = this.regex.exec(this._buffer)) { this.emit('match', match); lastMatch = match; + if (!this.regex.global) { + break; + } } if (lastMatch) { @@ -63,4 +66,3 @@ StreamSnitch.prototype.clearBuffer = function() { this._buffer = ''; return this; } -