diff --git a/src/cheerio.spec.ts b/src/cheerio.spec.ts index 89d6e0b2ca..ef4f19b83d 100644 --- a/src/cheerio.spec.ts +++ b/src/cheerio.spec.ts @@ -443,6 +443,8 @@ describe('cheerio', () => { expect(utils.isHtml('

fox

cat')).toBe(true); expect(utils.isHtml('\n

fox

cat\n')).toBe(true); expect(utils.isHtml('#

fox

cat#')).toBe(true); + expect(utils.isHtml('')).toBe(true); + expect(utils.isHtml('')).toBe(true); expect(utils.isHtml('<123>')).toBe(false); }); }); diff --git a/src/utils.ts b/src/utils.ts index c343927bdd..88f65930ee 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -113,7 +113,8 @@ export function isHtml(str: string): boolean { return ( ((tagChar >= 'a' && tagChar <= 'z') || - (tagChar >= 'A' && tagChar <= 'Z')) && + (tagChar >= 'A' && tagChar <= 'Z') || + tagChar === '!') && str.includes('>', tagStart + 2) ); }