Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export function getLinks(content, attributes) {
: attributes;

function processMatch(match, strUntilValue, name, value, index) {
if (!this.isRelevantTagAttr(this.currentTag, name)) {
if (!this.isRelevantTagAttribute(this.currentTag, name)) {
return;
}

Expand Down Expand Up @@ -428,16 +428,14 @@ export function getLinks(content, attributes) {
return parser.parse('outside', content, {
currentTag: null,
results: [],
isRelevantTagAttr: (tag, attribute) => {
const res = tagsAndAttributes.find((a) => {
if (a.startsWith(':')) {
return attribute === a.slice(1);
}
isRelevantTagAttribute: (tag, attribute) => {
return tagsAndAttributes.some((item) => {
const pattern = new RegExp(`^${item}$`, 'i');

return `${tag}:${attribute}` === a;
return (
pattern.test(`${tag}:${attribute}`) || pattern.test(`:${attribute}`)
);
});

return Boolean(res);
},
}).results;
}
Expand Down
282 changes: 168 additions & 114 deletions test/__snapshots__/attributes-option.test.js.snap

Large diffs are not rendered by default.

120 changes: 69 additions & 51 deletions test/__snapshots__/esModule-option.test.js.snap

Large diffs are not rendered by default.

40 changes: 23 additions & 17 deletions test/__snapshots__/loader.test.js.snap

Large diffs are not rendered by default.

237 changes: 132 additions & 105 deletions test/__snapshots__/minimize-option.test.js.snap

Large diffs are not rendered by default.

80 changes: 46 additions & 34 deletions test/__snapshots__/root-option.test.js.snap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/fixtures/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ <h2>An Ordered HTML List</h2>
<img src="~aliasImg">
<img src="">
<img src="image.png">
<IMG src="image.png">
<img SRC="image.png">
<IMG SRC="image.png">

<script src="script.js"></script>

Expand Down