





















@@ -97,17 +97,21 @@ describe("toSanitizedMarkdownHtml", () => {
9797it("handles quotes with balance checking", () => {
9898// Quoted URL — trailing unbalanced " is stripped
9999const html1 = toSanitizedMarkdownHtml('"www.example.com"');
100-expect(html1).toContain('href="http://www.example.com"');
101-expect(html1).not.toContain('href="http://www.example.com%22"');
100+expect(html1).toBe(
101+'<p>"<a href="http://www.example.com" rel="noreferrer noopener" target="_blank">www.example.com</a>"</p>\n',
102+);
102103103104// Balanced quotes inside path — preserved
104105const html2 = toSanitizedMarkdownHtml('www.example.com/path"with"quotes');
105-expect(html2).toContain('www.example.com/path"with"quotes</a>');
106+expect(html2).toBe(
107+'<p><a href="http://www.example.com/path%22with%22quotes" rel="noreferrer noopener" target="_blank">www.example.com/path"with"quotes</a></p>\n',
108+);
106109107110// Trailing unbalanced " — stripped
108111const html3 = toSanitizedMarkdownHtml('www.example.com/path"');
109-expect(html3).toContain('href="http://www.example.com/path"');
110-expect(html3).not.toContain('path%22"');
112+expect(html3).toBe(
113+'<p><a href="http://www.example.com/path" rel="noreferrer noopener" target="_blank">www.example.com/path</a>"</p>\n',
114+);
111115});
112116113117it("does NOT link www. domains starting with non-ASCII", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。