import { escape } from "lodash-es"; export const PLAIN_LINK_REG = /(https?:\/\/[^ ]+)/; const matcher = (rawStr: string) => { const matchResult = rawStr.match(PLAIN_LINK_REG); return matchResult; }; const renderer = (rawStr: string): string => { const matchResult = matcher(rawStr); if (!matchResult) { return rawStr; } return `${escape(matchResult[1])}`; }; export default { name: "plain link", regex: PLAIN_LINK_REG, matcher, renderer, };