const REGEX_URL = /[^">](https?:\/\/[^\s<]+)/g;
const REGEX_A = //g;
export default {
urlify(text: string|undefined): string {
if (!text) {
return "";
}
// Add target="_blank" to
const withTarget = text.replace(REGEX_A, (full: string, content: string) => {
if (full.includes('target="_blank"')) {
return full;
} else {
return '';
}
});
// Convert URL to
return withTarget.replace(REGEX_URL, (url: string) => {
return (
'' + url + ""
);
});
},
async onCopyCode(link: string, callback: () => void): Promise {
await navigator.clipboard.writeText(link);
return callback();
},
};