Skip to content

Commit

Permalink
fix: don't crash but gracefully ignore undefined for wildcard keypaths
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Feb 26, 2023
1 parent 53feb48 commit d05e39a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/expand-wildcard-keypath.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ function expandWildcardKeypath(root, keypaths, char) {
if (wildcard > -1) {
const pre = keypath.slice(0, wildcard)
const wildcardRoot = get(root, pre)

if (!wildcardRoot) return result
const looped = isArray(wildcardRoot) ? wildcardRoot : Object.keys(wildcardRoot)

looped.forEach((entry, index) => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function markdown(options = defaultOptions) {
set(data, key, options.render(globalRefsMarkdown + value, options.engineOptions, { path: file, key }))
// log a warning if the key is defined and of an unexpected type, but not if the property simply is not defined
} else if (typeof value !== 'undefined') {
debug.warn('Couldn\'t render key %s of file "%s": not a string', key.join ? key.join('.') : key, file)
debug.warn('Couldn\'t render key "%s" of file "%s": not a string', key.join ? key.join('.') : key, file)
}
})

Expand Down
Empty file.
Empty file.

0 comments on commit d05e39a

Please sign in to comment.