Skip to content

Commit 1bb6bd0

Browse files
fix: do not handle empty attributes (#210)
1 parent ec9994f commit 1bb6bd0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function htmlLoader(source) {
4343
let offset = 0;
4444
for (const link of links) {
4545
if (
46+
link.value &&
4647
isUrlRequest(link.value, options.root) &&
4748
!link.value.includes('mailto:')
4849
) {

test/loader.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ describe('loader', () => {
77
it('should convert to requires', () => {
88
const result = loader.call(
99
{},
10-
'Text <img src="image.png"><img src="~bootstrap-img"> Text'
10+
'Text <img src="image.png"><img src="~bootstrap-img"> Text <img src="">'
1111
);
1212

1313
expect(result).toBe(
14-
`${GET_URL_CODE}module.exports = "Text <img src=\\"" + __url__(require("./image.png")) + "\\"><img src=\\"" + __url__(require("bootstrap-img")) + "\\"> Text";`
14+
`${GET_URL_CODE}module.exports = "Text <img src=\\"" + __url__(require("./image.png")) + "\\"><img src=\\"" + __url__(require("bootstrap-img")) + "\\"> Text <img src=\\\"\\\">";`
1515
);
1616
});
17+
1718
it('should accept attrs from query', () => {
1819
const result = loader.call(
1920
{

0 commit comments

Comments
 (0)