Skip to content

Commit 1a61ee7

Browse files
committed
replacing hompage links can break images.. only replace if they don't include wp-content, etc
1 parent a9b139c commit 1a61ee7

File tree

1 file changed

+5
-1
lines changed
  • packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes

1 file changed

+5
-1
lines changed

packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/process-node.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,11 @@ const replaceNodeHtmlLinks = ({ wpUrl, nodeString, node }) => {
827827
const normalizedPath = path.replace(/\\/g, ``)
828828

829829
// replace normalized match with relative path
830-
const thisMatchRegex = new RegExp(normalizedMatch, `g`)
830+
const thisMatchRegex = new RegExp(
831+
normalizedMatch + `(?!/?wp-content|/?wp-admin|/?wp-includes)`,
832+
`g`
833+
)
834+
831835
nodeString = nodeString.replace(thisMatchRegex, normalizedPath)
832836
} catch (e) {
833837
console.error(e)

0 commit comments

Comments
 (0)