Skip to content

Fix to only handle events once an empty line is present.#39

Closed
GidoHakvoort wants to merge 2 commits intobinaryminds:masterfrom
GidoHakvoort:master
Closed

Fix to only handle events once an empty line is present.#39
GidoHakvoort wants to merge 2 commits intobinaryminds:masterfrom
GidoHakvoort:master

Conversation

@GidoHakvoort
Copy link

Fix to only handle events once an empty line is present.

When events are sent as multipart messages onreadystatechange will be called multiple times. Since response.substr(this.lastIndexProcessed).split('\n') also return an empty string with only 1 newline, dispatch will also be called multiple time (e.g. "event: add\n data: 4\n".split('\n') will give [ "event: add", " data: 4", "" ]). This fix will check if indeed (a new) empty line is present before processing the event.

Fix to only handle events once an empty line is present.
Fix to only process events with empty line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant