Skip to content

Commit d05e39a

Browse files
committed
fix: don't crash but gracefully ignore undefined for wildcard keypaths
1 parent 53feb48 commit d05e39a

File tree

4 files changed

+3
-1
lines changed

4 files changed

+3
-1
lines changed

src/expand-wildcard-keypath.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function expandWildcardKeypath(root, keypaths, char) {
4848
if (wildcard > -1) {
4949
const pre = keypath.slice(0, wildcard)
5050
const wildcardRoot = get(root, pre)
51+
52+
if (!wildcardRoot) return result
5153
const looped = isArray(wildcardRoot) ? wildcardRoot : Object.keys(wildcardRoot)
5254

5355
looped.forEach((entry, index) => {

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function markdown(options = defaultOptions) {
112112
set(data, key, options.render(globalRefsMarkdown + value, options.engineOptions, { path: file, key }))
113113
// log a warning if the key is defined and of an unexpected type, but not if the property simply is not defined
114114
} else if (typeof value !== 'undefined') {
115-
debug.warn('Couldn\'t render key %s of file "%s": not a string', key.join ? key.join('.') : key, file)
115+
debug.warn('Couldn\'t render key "%s" of file "%s": not a string', key.join ? key.join('.') : key, file)
116116
}
117117
})
118118

test/fixtures/array-index-keys/src/empty.md

Whitespace-only changes.

test/fixtures/nested-keys/src/empty.md

Whitespace-only changes.

0 commit comments

Comments
 (0)