diff --git a/test/test_site/testUtil/diffHtml.js b/test/test_site/testUtil/diffHtml.js
index 5a6c703dc4..db4fe2dd3f 100644
--- a/test/test_site/testUtil/diffHtml.js
+++ b/test/test_site/testUtil/diffHtml.js
@@ -21,16 +21,21 @@ const endsWithUnclosedPath = (fragment) => {
/**
* Checks if the ending portion of the fragment is inside an html tag
* true: link" src=".../
* false: src="..
*
+ * src="...
*/
const endsWithOpeningTag = (fragment) => {
+ let numUnmatchedClosingBracket = 0;
for (let i = fragment.length - 1; i >= 0; i -= 1) {
- if (fragment[i] === '<') {
- return true;
- }
if (fragment[i] === '>') {
- return false;
+ numUnmatchedClosingBracket += 1;
+ } else if (fragment[i] === '<') {
+ if (numUnmatchedClosingBracket === 0) {
+ return true;
+ }
+ numUnmatchedClosingBracket -= 1;
}
}
return false;