Skip to content

Commit

Permalink
Handle invalid JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham42 committed Feb 17, 2021
1 parent 2ad4438 commit bd125a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/json-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ const jsonSourceMap = require("json-source-map");
* @returns {string|null}
*/
function getJsonPathFromRawLocation(rawJson, location) {
let { pointers } = jsonSourceMap.parse(rawJson);
let parsed = { pointers: {} };
try {
parsed = jsonSourceMap.parse(rawJson);
} catch (err) {
return null;
}
let { pointers } = parsed;
let pathEntry = Object.entries(pointers).find(
/** @param {[string, Pointer]} e */
([path, pointer]) => {
Expand Down

0 comments on commit bd125a0

Please sign in to comment.