Skip to content

Commit ffd8e5c

Browse files
committed
fix: scope video keyword match to iframe/embed elements
matchesKeyword in is-video-detected.js was checking the "src" attribute of any element matched by the rule's broad selector (video, iframe, object, source, [src]:not(script), [role]) for substrings like "youtube" or "vimeo". Since the selector includes any [src] element, this flagged plain <img> tags whose filename happened to contain one of these words, most commonly a featured image screenshot named like "...-youtube.jpg". Restrict the keyword check to iframe/embed elements, which is where a "youtube"/"vimeo" URL actually indicates an embedded video player. Fixes PRO-1229.
1 parent 5198836 commit ffd8e5c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/pageScanner/checks/is-video-detected.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ export default {
5858
return matches;
5959
} );
6060

61-
const matchesKeyword = videoKeywords.some( ( keyword ) =>
62-
srcLower.includes( keyword )
63-
);
61+
// Keyword matching (youtube/vimeo/etc.) is only meaningful for embed-style
62+
// elements whose src is a URL to a video player. Applying it to any [src]
63+
// element (e.g. <img>) causes false positives when a filename merely
64+
// contains one of these words, such as a screenshot named
65+
// "...-youtube.jpg" used as a featured image.
66+
const matchesKeyword = ( tag === 'iframe' || tag === 'embed' ) &&
67+
videoKeywords.some( ( keyword ) => srcLower.includes( keyword ) );
6468

6569
const matchesType = type.toLowerCase().startsWith( 'video/' );
6670

0 commit comments

Comments
 (0)