From 2e06b06c8f60410421c5b093c56dcff96f8b5953 Mon Sep 17 00:00:00 2001 From: nicholaschuayunzhi Date: Tue, 16 Oct 2018 20:38:08 -0400 Subject: [PATCH] Account for closing html tags during diff --- test/test_site/testUtil/diffHtml.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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;