Skip to content

Commit ec8be04

Browse files
authored
Handle non-JSON arguments (#233)
* 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
1 parent 2ba78c1 commit ec8be04

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/helpers/obj.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
'use strict'
22

3-
module.exports = (a) => JSON.parse(a)
3+
module.exports = (a) => {
4+
if (typeof a === 'undefined' || a === null) {
5+
return {}
6+
}
7+
return JSON.parse(a)
8+
}

0 commit comments

Comments
 (0)