Improve link matching regex for instant view

This commit is contained in:
dangered wolf 2024-08-04 11:26:44 -07:00
parent bfbd102cc3
commit 174cc65782
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -69,7 +69,7 @@ const formatDate = (date: Date, language: string): string => {
};
const htmlifyLinks = (input: string): string => {
const urlPattern = /\bhttps?:\/\/[\w.-]+\.\w+[/\w.-]*\w/g;
const urlPattern = /\bhttps?:\/\/(\w+(-\w+)*\.)+[a-z]{2,}(:\d+)?(\/[-\w@:%_+.~#?&/=]*)?/gi;
return input.replace(urlPattern, url => {
return `<a href="${wrapForeignLinks(url)}">${url}</a>`;
});