From 2dfafe2df4cdc5b4a570b20613929a27496007c5 Mon Sep 17 00:00:00 2001 From: taoqf Date: Sat, 29 Feb 2020 11:42:03 +0800 Subject: [PATCH] :bug: #30 --- src/index.ts | 8 +++++++- test/html.js | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 103d692..a8cee1c 100755 --- a/src/index.ts +++ b/src/index.ts @@ -113,7 +113,13 @@ export function parse(data: string, options = {} as Options) { if (kBlockTextElements[match[2]]) { // a little test to find next or ... const closeMarkup = ''; - const index = data.indexOf(closeMarkup, kMarkupPattern.lastIndex); + const index = (() => { + if (options.lowerCaseTagName) { + return data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex); + } else { + return data.indexOf(closeMarkup, kMarkupPattern.lastIndex); + } + })(); if (options[match[2]]) { let text: string; if (index === -1) { diff --git a/test/html.js b/test/html.js index 0ea581d..054d7cf 100644 --- a/test/html.js +++ b/test/html.js @@ -83,6 +83,18 @@ describe('HTML Parser', function () { }); + it('should deal uppercase', function () { + const html = 'SISREG III

CONSULTA AO CADASTRO DE PACIENTES SUS



Processando...


'; + + var root = parseHTML(html, { + lowerCaseTagName: true + }); + + root.toString().should.eql('SISREG III

CONSULTA AO CADASTRO DE PACIENTES SUS



Processando...


'); + // root.toString().firstChild.should.eql(div); + + }); + it('should parse "

" and return root element', function () { var root = parseHTML('

');