-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix data split delimiter #280
Conversation
+1 |
I'm a little wary of the precedence of the | in this regex and I want to torture-test it a bit before merging. |
I do not think this regex works in full generality. Consider the following:
Can you consider the second regex in this example for your pull req, or point out where I've misunderstood? Thanks! |
@apeiron Great catch. We may also want to consider compiling the regex out of scope of the listener so it doesn't have to be created for every chunk of data coming in. |
@jirwin Ok, I moved the regex. @apeiron thanks! I overlooked that's pattern. But, I think you should delete var string = 'hello\nthere\nworld\r\nstuff'
var badRe = new RegExp('\r\n|\r|\n')
var badResult = string.split(badRe)
console.dir(badResult);
var goodRe = new RegExp('(?:\r\n)|\n|\r')
var goodResult = string.split(goodRe);
console.dir(goodResult)
var isEqual = (badResult.length == goodResult.length)
for (var i = 0; i < badResult.length; ++i) {
if (badResult[i] !== goodResult[i]){
isEqual = false
}
}
console.dir(isEqual) # true I think Probably, the RegExp object interpret it as So I fixed code using |
This needs rebasing, because we just merged #278. |
d199bdf
to
84c2110
Compare
I rebased. |
+1 |
IRC Protocol use CR-LF, but legacy IRC server send other code.
http://tools.ietf.org/html/rfc1459.html#section-8
So, replace split string from \r\n with /\r\n|\r|\n/