Skip to content

Commit

Permalink
refactor: trim parse data to prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleoutIce committed Nov 28, 2024
1 parent f1af48d commit 23d68e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/r-bridge/lang-4.x/ast/parser/json/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ type ParsedDataRow = [line1: number, col1: number, line2: number, col2: number,
export function prepareParsedData(data: string): CsvEntry[] {
let json: unknown;
try {
json = JSON.parse(`[${data}]`);
json = JSON.parse(`[${data.trim()}]`);
} catch(e) {
throw new Error(`Failed to parse data ${data}: ${(e as Error)?.message}`);
throw new Error(`Failed to parse data [${data}]: ${(e as Error)?.message}`);
}
guard(Array.isArray(json), () => `Expected ${data} to be an array but was not`);

Expand Down

0 comments on commit 23d68e5

Please sign in to comment.