Skip to content

Commit 69d8fde

Browse files
authored
Allow CRLF when parsing close tag name. (#36)
1 parent 1d998cf commit 69d8fde

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/constants/regex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export const CLOSING_STYLE_TAG_PATTERN = /<\/style\s*>/i;
66

77
export const OPEN_TAG_NAME_PATTERN = /^<(\S+)/;
88

9-
export const CLOSE_TAG_NAME_PATTERN = /^<\/((?:.|\n)*)>$/;
9+
export const CLOSE_TAG_NAME_PATTERN = /^<\/((?:.|\r?\n)*)>$/;

src/utils/__tests__/parse-close-tag-name.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ describe("parseCloseTagName", () => {
55
expect(parseCloseTagName("</div>")).toBe("div");
66
});
77

8+
it("Should return close tag name when close tag has LF newline before closing caret", () => {
9+
const closeTag = `</div\n>`;
10+
expect(parseCloseTagName(closeTag)).toBe("div");
11+
});
12+
13+
it("Should return close tag name when close tag has CRLF newline before closing caret", () => {
14+
const closeTag = `</div\r\n>`;
15+
expect(parseCloseTagName(closeTag)).toBe("div");
16+
});
17+
818
it("Should throw error", () => {
919
expect(() => parseCloseTagName("<div>")).toThrowError();
1020
});

0 commit comments

Comments
 (0)