Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check markdown images, ensure parent is File before referencing dir #3831

Merged
merged 2 commits into from
Feb 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/gatsby-remark-copy-linked-files/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ module.exports = (
return
}

// since dir will be undefined on non-files
if (getNode(markdownNode.parent).internal.type !== `File`) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to check if there is a parent as well since a markdown node doesn't necessarily need a parent.

return
}

const imagePath = path.posix.join(
getNode(markdownNode.parent).dir,
image.url
Expand Down