Skip to content

Commit

Permalink
Handle non-JSON arguments (#233)
Browse files Browse the repository at this point in the history
* Handle non-JSON arguments

When this is unhandled, the error propagates to Antora and results in a failed build. For example:

```
FATAL (antora): Unexpected token u in JSON at position 0 in UI template partials/bloblang-playground.hbs
```

This handles the error gracefully and allows our templates to ignore empty objects

* Update obj.js
  • Loading branch information
JakeSCahill authored Dec 3, 2024
1 parent 2ba78c1 commit ec8be04
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/helpers/obj.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
'use strict'

module.exports = (a) => JSON.parse(a)
module.exports = (a) => {
if (typeof a === 'undefined' || a === null) {
return {}
}
return JSON.parse(a)
}

0 comments on commit ec8be04

Please sign in to comment.