From 928914e14e321646a814ad44c4ff9108e37478fe Mon Sep 17 00:00:00 2001 From: Sam Bhagwat Date: Sun, 4 Feb 2018 08:59:14 -0800 Subject: [PATCH] check markdown images, ensure parent is File before referencing dir (#3831) * check markdown images, ensure parent is File before referencing dir * add check for parent --- packages/gatsby-remark-copy-linked-files/src/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/gatsby-remark-copy-linked-files/src/index.js b/packages/gatsby-remark-copy-linked-files/src/index.js index 229a8830d908f..2ab0b7f8e6ae9 100644 --- a/packages/gatsby-remark-copy-linked-files/src/index.js +++ b/packages/gatsby-remark-copy-linked-files/src/index.js @@ -149,6 +149,14 @@ module.exports = ( return } + // since dir will be undefined on non-files + if ( + markdownNode.parent && + getNode(markdownNode.parent).internal.type !== `File` + ) { + return + } + const imagePath = path.posix.join( getNode(markdownNode.parent).dir, image.url