-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gatsby-source-wordpress): HTML image regex's (#29778)
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com> (cherry picked from commit f6edccf)
- Loading branch information
1 parent
9ecbc81
commit f70cb1d
Showing
3 changed files
with
68 additions
and
31 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/gatsby-source-wordpress/__tests__/process-node.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { | ||
getImgSrcRemoteFileMatchesFromNodeString, | ||
getImgTagMatchesWithUrl, | ||
} from "../dist/steps/source-nodes/create-nodes/process-node" | ||
|
||
test(`HTML image transformation regex matches images`, async () => { | ||
const wpUrl = `http://wp.fakesite.com` | ||
|
||
const nodeString = `<img src=\\"https://wp.fakesite.com/wp-content/uploads/2020/01/©SDM-Yep-©Hi-000-Header.jpg /> | ||
<img src=\\"http://wp.fakesite.com/wp-content/uploads/2020/01/©SDM-Yep-©Hi-000-Header.jpg /> | ||
<img src=\\"/wp-content/uploads/2020/01/©SDM-Yep-©Hi-000-Header.jpg />` | ||
|
||
const matches = getImgSrcRemoteFileMatchesFromNodeString(nodeString) | ||
|
||
expect(matches.length).toBe(3) | ||
|
||
const imgTagMatches = getImgTagMatchesWithUrl({ | ||
nodeString, | ||
wpUrl, | ||
}) | ||
|
||
expect(imgTagMatches.length).toBe(3) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters