MCPcopy
hub / github.com/su-kaka/gcli2api / linkifyText

Function linkifyText

front/common.js:550–565  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

548
549// 将文本中的链接转换为可点击的HTML链接
550function linkifyText(text) {
551 if (!text) return text;
552
553 // 匹配 http://, https:// 和 www. 开头的链接,排除常见的标点符号
554 const urlPattern = /(https?:\/\/[^\s"'<>()[\]{}]+)|(www\.[^\s"'<>()[\]{}]+)/gi;
555
556 return text.replace(urlPattern, function(url) {
557 let href = url;
558 // 如果是 www. 开头,添加 https://
559 if (url.startsWith('www.')) {
560 href = 'https://' + url;
561 }
562
563 return `<a href="${href}" target="_blank" rel="noopener noreferrer" class="message-link" onclick="event.stopPropagation()" title="点击打开链接\n右键复制链接">${url}</a>`;
564 });
565}
566
567// 显示增强的消息模态框(支持链接高亮)
568function showMessageModal(title, message, type = 'info') {

Callers 1

showMessageModalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected