diff --git a/src/constants/regex.ts b/src/constants/regex.ts index f660663..699124c 100644 --- a/src/constants/regex.ts +++ b/src/constants/regex.ts @@ -6,4 +6,4 @@ export const CLOSING_STYLE_TAG_PATTERN = /<\/style\s*>/i; export const OPEN_TAG_NAME_PATTERN = /^<(\S+)/; -export const CLOSE_TAG_NAME_PATTERN = /^<\/((?:.|\n)*)>$/; +export const CLOSE_TAG_NAME_PATTERN = /^<\/((?:.|\r?\n)*)>$/; diff --git a/src/utils/__tests__/parse-close-tag-name.spec.ts b/src/utils/__tests__/parse-close-tag-name.spec.ts index c88b6c1..a24f833 100644 --- a/src/utils/__tests__/parse-close-tag-name.spec.ts +++ b/src/utils/__tests__/parse-close-tag-name.spec.ts @@ -5,6 +5,16 @@ describe("parseCloseTagName", () => { expect(parseCloseTagName("")).toBe("div"); }); + it("Should return close tag name when close tag has LF newline before closing caret", () => { + const closeTag = ``; + expect(parseCloseTagName(closeTag)).toBe("div"); + }); + + it("Should return close tag name when close tag has CRLF newline before closing caret", () => { + const closeTag = ``; + expect(parseCloseTagName(closeTag)).toBe("div"); + }); + it("Should throw error", () => { expect(() => parseCloseTagName("
")).toThrowError(); });