@@ -25,23 +25,30 @@ describe("toSanitizedMarkdownHtml", () => {
|
25 | 25 | describe("www autolinks", () => { |
26 | 26 | it("links www.example.com", () => { |
27 | 27 | const html = toSanitizedMarkdownHtml("Visit www.example.com today"); |
28 | | -expect(html).toContain('<a href="http://www.example.com"'); |
29 | | -expect(html).toContain("www.example.com</a>"); |
| 28 | +expect(html).toBe( |
| 29 | +'<p>Visit <a href="http://www.example.com" rel="noreferrer noopener" target="_blank">www.example.com</a> today</p>\n', |
| 30 | +); |
30 | 31 | }); |
31 | 32 | |
32 | 33 | it("links www.example.com with path, query, and fragment", () => { |
33 | 34 | const html = toSanitizedMarkdownHtml("See www.example.com/path?a=1#section"); |
34 | | -expect(html).toContain('<a href="http://www.example.com/path?a=1#section"'); |
| 35 | +expect(html).toBe( |
| 36 | +'<p>See <a href="http://www.example.com/path?a=1#section" rel="noreferrer noopener" target="_blank">www.example.com/path?a=1#section</a></p>\n', |
| 37 | +); |
35 | 38 | }); |
36 | 39 | |
37 | 40 | it("links www.example.com with port", () => { |
38 | 41 | const html = toSanitizedMarkdownHtml("Visit www.example.com:8080/foo"); |
39 | | -expect(html).toContain('<a href="http://www.example.com:8080/foo"'); |
| 42 | +expect(html).toBe( |
| 43 | +'<p>Visit <a href="http://www.example.com:8080/foo" rel="noreferrer noopener" target="_blank">www.example.com:8080/foo</a></p>\n', |
| 44 | +); |
40 | 45 | }); |
41 | 46 | |
42 | 47 | it("links www.localhost and other single-label hosts", () => { |
43 | 48 | const html = toSanitizedMarkdownHtml("Visit www.localhost:3000/path for dev"); |
44 | | -expect(html).toContain('<a href="http://www.localhost:3000/path"'); |
| 49 | +expect(html).toBe( |
| 50 | +'<p>Visit <a href="http://www.localhost:3000/path" rel="noreferrer noopener" target="_blank">www.localhost:3000/path</a> for dev</p>\n', |
| 51 | +); |
45 | 52 | }); |
46 | 53 | |
47 | 54 | it("links Unicode/IDN domains like www.münich.de", () => { |
|