feat: sanitize HTML in footer
moved sanitize function into a separate file including some simple tests closes #91
This commit is contained in:
committed by
Bastian
parent
5a5928f2dd
commit
e0113c446d
20
src/sanitize.test.tsx
Normal file
20
src/sanitize.test.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { sanitize } from "./sanitize";
|
||||
|
||||
describe("sanitize", () => {
|
||||
it("should sanitize the string input to HTML output", () => {
|
||||
let res = sanitize('foo');
|
||||
expect(res.__html).toEqual("foo");
|
||||
res = sanitize('<a href="https://example.org">Example.org</a>');
|
||||
expect(res.__html).toEqual("<a href=\"https://example.org\">Example.org</a>");
|
||||
});
|
||||
it("should not sanitize not allowed tags", () => {
|
||||
let res = sanitize('Before <iframe src="https://example.org"></iframe> After');
|
||||
expect(res.__html).toEqual("Before After");
|
||||
});
|
||||
it("should accept options for rendering", () => {
|
||||
let res = sanitize('<a href="https://example.org" target="_blank">Example.org</a>', { allowedAttributes: { a: ['href']}});
|
||||
expect(res.__html).toEqual("<a href=\"https://example.org\">Example.org</a>");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user