laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
17 lines (16 loc) • 752 B
JavaScript
"use client";
import { toString as l } from "../../../mdast-util-to-string/lib/index.js";
function c(t, i) {
const r = l(t);
return !!(!i.options.resourceLink && // If there’s a url…
t.url && // And there’s a no title…
!t.title && // And the content of `node` is a single text node…
t.children && t.children.length === 1 && t.children[0].type === "text" && // And if the url is the same as the content…
(r === t.url || "mailto:" + r === t.url) && // And that starts w/ a protocol…
/^[a-z][a-z+.-]+:/i.test(t.url) && // And that doesn’t contain ASCII control codes (character escapes and
// references don’t work), space, or angle brackets…
!/[\0- <>\u007F]/.test(t.url));
}
export {
c as formatLinkAsAutolink
};