From 1ba29f94cb066b19573b7c487fb1b02e9bab2b4e Mon Sep 17 00:00:00 2001 From: Joshua Koo Date: Wed, 6 Jan 2021 20:10:31 -0800 Subject: [PATCH] Fix a bug where CIDs is not updated correctly In ParserPCAP.ts, CIDs is not updated correctly when a new CID is in index 0 of the client/serverIssuedCIDs. `.indexOf()` should be used with `> -1` to check existence of a member, otherwise `.includes()` would be the better method (available with ECMAScript 2016) --- src/parsers/ParserPCAP.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parsers/ParserPCAP.ts b/src/parsers/ParserPCAP.ts index 1a18bac..90daf4b 100644 --- a/src/parsers/ParserPCAP.ts +++ b/src/parsers/ParserPCAP.ts @@ -460,7 +460,7 @@ export class ParserPCAP { } // server issued this CID, so the client can use it to contact the server - if ( trace.serverIssuedCIDs.indexOf(header.dcid!) ) { // if undefined, it's just not initialized yet: skip + if ( trace.serverIssuedCIDs.includes(header.dcid!) ) { // if undefined, it's just not initialized yet: skip this.addEvent(trace, [ // Log the change of cid "" + trace.currentTime, @@ -475,7 +475,7 @@ export class ParserPCAP { trace.currentServerCID = header.dcid; } - else if ( trace.clientIssuedCIDs.indexOf(header.dcid!) ) { + else if ( trace.clientIssuedCIDs.includes(header.dcid!) ) { this.addEvent(trace, [ // Log the change of cid "" + trace.currentTime,