我们如何添加允许域的白名单?使用:linkify-it add
我尝试过:
// regex
this.md.linkify.add("", /github[.]com/);
// string
this.md.linkify.add("", "github.com");
this.md.linkify.add("github.com", true);
我正在使用MarkdownIt npm软件包,带有linkify插件:
const MarkdownIt = require("markdown-it");
this.md = MarkdownIt({
typographer: true,
linkify: true
});
// WHITELIST (allowed domains)
this.md.linkify.add("", /[github.com]/);
预期结果如下:
// should print true
console.log("DOMAIN ALLOWED TEST", this.md.linkify.test("Site github.com!"));
// should print false
console.log("DOMAIN BLOCKED TEST", this.md.linkify.test("Site githubs.com!"));