@@ -70,23 +70,28 @@ describe("toSanitizedMarkdownHtml", () => {
|
70 | 70 | |
71 | 71 | it("strips trailing punctuation from links", () => { |
72 | 72 | const html1 = toSanitizedMarkdownHtml("Check www.example.com/help."); |
73 | | -expect(html1).toContain('href="http://www.example.com/help"'); |
74 | | -expect(html1).not.toContain('href="http://www.example.com/help."'); |
| 73 | +expect(html1).toBe( |
| 74 | +'<p>Check <a href="http://www.example.com/help" rel="noreferrer noopener" target="_blank">www.example.com/help</a>.</p>\n', |
| 75 | +); |
75 | 76 | |
76 | 77 | const html2 = toSanitizedMarkdownHtml("See www.example.com!"); |
77 | | -expect(html2).toContain('href="http://www.example.com"'); |
78 | | -expect(html2).not.toContain('href="http://www.example.com!"'); |
| 78 | +expect(html2).toBe( |
| 79 | +'<p>See <a href="http://www.example.com" rel="noreferrer noopener" target="_blank">www.example.com</a>!</p>\n', |
| 80 | +); |
79 | 81 | }); |
80 | 82 | |
81 | 83 | it("strips entity-like suffixes per GFM spec", () => { |
82 | 84 | // &hl; looks like an entity reference, so strip it |
83 | 85 | const html1 = toSanitizedMarkdownHtml("www.google.com/search?q=commonmark&hl;"); |
84 | | -expect(html1).toContain('href="http://www.google.com/search?q=commonmark"'); |
85 | | -expect(html1).toContain("&hl;"); // Entity shown outside link |
| 86 | +expect(html1).toBe( |
| 87 | +'<p><a href="http://www.google.com/search?q=commonmark" rel="noreferrer noopener" target="_blank">www.google.com/search?q=commonmark</a>&hl;</p>\n', |
| 88 | +); |
86 | 89 | |
87 | 90 | // & is also entity-like |
88 | 91 | const html2 = toSanitizedMarkdownHtml("www.example.com/path&"); |
89 | | -expect(html2).toContain('href="http://www.example.com/path"'); |
| 92 | +expect(html2).toBe( |
| 93 | +'<p><a href="http://www.example.com/path" rel="noreferrer noopener" target="_blank">www.example.com/path</a>&</p>\n', |
| 94 | +); |
90 | 95 | }); |
91 | 96 | |
92 | 97 | it("handles quotes with balance checking", () => { |
|