behavior formatMessages init set container to me js(container) var message = container.innerHTML; function convertToURL(inputString) { // Regular expression to match URLs in the input string // 1. http://xxx // 2. https://xxx // 3. www.xxx // 4. xxx.com // 5. xxx.io // 6. xxx.ai const urlRegex = /(https?:\/\/[^\s]+)|(www\.[^\s]+)|(\b\w+\.(com|io|ai)\b)/g; // Replace URLs in the input string with anchor tags const convertedString = inputString.replace(urlRegex, function(url) { if (url.startsWith("www.") || url.endsWith(".com") || url.endsWith(".io") || url.endsWith(".ai")) { return '' + url + ''; } return '' + url + ''; }); return convertedString; } // Format URLs container.innerHTML = convertToURL(message); end end end