Skip to content

Commit cd83a60

Browse files
committed
Skip img tag with blank url
1 parent 0600d7c commit cd83a60

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/extractItemsFromElement.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ function extractItemsFromElement(childNode) {
3232
}
3333
// if element is img -> create img section
3434
if (childNode.tagName === IMG_TAG_NAME) {
35-
items.push(new ImageItem(childNode.src));
35+
if (!isBlankText(childNode.src)) {
36+
items.push(new ImageItem(childNode.src));
37+
}
3638
}
3739

3840
return items;

test/convertDescriptionToItems.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,21 @@ describe("convertDescriptionToItems", () => {
172172
items.should.eql(expectedItems);
173173
});
174174

175+
given("", " ").it("should skip img tag with blank url", (url) => {
176+
// given
177+
const html = givenHtmlWithContent(`
178+
<img src="${url}" />
179+
<div>This is a test text</div>
180+
`);
181+
182+
// when
183+
const items = convertDescriptionToItems(html, options);
184+
185+
// then
186+
const expectedItems = [new TextItem("<p>This is a test text</p>")];
187+
items.should.eql(expectedItems);
188+
});
189+
175190
it("should skip tag containing html that converts to empty standardized html", () => {
176191
// given
177192
const html = givenHtmlWithContent(`

0 commit comments

Comments
 (0)