Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/constants/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)*)>$/;
10 changes: 10 additions & 0 deletions src/utils/__tests__/parse-close-tag-name.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ describe("parseCloseTagName", () => {
expect(parseCloseTagName("</div>")).toBe("div");
});

it("Should return close tag name when close tag has LF newline before closing caret", () => {
const closeTag = `</div\n>`;
expect(parseCloseTagName(closeTag)).toBe("div");
});

it("Should return close tag name when close tag has CRLF newline before closing caret", () => {
const closeTag = `</div\r\n>`;
expect(parseCloseTagName(closeTag)).toBe("div");
});

it("Should throw error", () => {
expect(() => parseCloseTagName("<div>")).toThrowError();
});
Expand Down
Loading