Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pipeline/parse/JSONStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ export class JSONStream {
break;

case State.END_VALUE_ARRAY:
// console.log("EMITTING ARRAY", this.key, this.value);
this.arrayCallbacks[this.key!](this.parseValue());
// Check if the captured value is actually empty/whitespace
if (this.buffer.slice(this.valueStart, i).trim().length > 0) {
// console.log("EMITTING ARRAY", this.key, this.value);
this.arrayCallbacks[this.key!](this.parseValue());
}

// read next item
this.state = State.NEXT_ARRAY_ITEM;
Expand Down
1 change: 1 addition & 0 deletions tests/parse/Parsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { loadSample } from "@tests/samples";
describe("should parse correctly", () => {
// prettier-ignore
const cases: { parser: new () => Parser; inputs: string[] }[] = [
{ parser: DiscordParser, inputs: ["discord/DM_0A_0M.json"] },
{ parser: DiscordParser, inputs: ["discord/DM_2A_2M.json"] },
{ parser: DiscordParser, inputs: ["discord/GC_3A_5M.json"] },
{ parser: DiscordParser, inputs: ["discord/SV_5A_5M.json"] },
Expand Down
21 changes: 21 additions & 0 deletions tests/samples/discord/DM_0A_0M.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"guild": {
"id": "0",
"name": "Direct Messages",
"iconUrl": "https://cdn.discordapp.com/embed/avatars/0.png"
},
"channel": {
"id": "530805775262679064",
"type": "DirectTextChat",
"categoryId": "0",
"category": "Private",
"name": "Someones name",
"topic": null
},
"dateRange": {
"after": null,
"before": null
},
"messages": [],
"messageCount": 0
}
16 changes: 16 additions & 0 deletions tests/samples/discord/DM_0A_0M.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ExpectedPartialParseResult } from "@tests/parse/Parse";
import { PGUILD_DM } from "@tests/samples/discord/Common";

export const expectedParse: ExpectedPartialParseResult = {
guilds: [PGUILD_DM],
channels: [
{
id: "530805775262679064",
type: "dm",
avatar: undefined,
},
],
authors: [],
messages: [],
calls: [],
};