Fix link regex to not catch periods at the end of links

This commit is contained in:
Jon Staab
2024-09-06 14:09:18 -07:00
parent 1a480e5890
commit df3efdee59
+1 -1
View File
@@ -217,7 +217,7 @@ export const parseInvoice = (text: string, context: ParseContext): ParsedInvoice
export const parseLink = (text: string, context: ParseContext): ParsedLink | void => {
const prev = last(context.results)
const [link] = text.match(/^([a-z\+:]{2,30}:\/\/)?[^<>\(\)\s]+\.[a-z]{2,6}[^\s]*[^<>"'\.!?,:\s\)\(]*/gi) || []
const [link] = text.match(/^([a-z\+:]{2,30}:\/\/)?[-\.~\w]+\.[\w]{2,6}([^\s]*[^<>"'\.!,:\s\)\(]+)?/gi) || []
// Skip url if it's just the end of a filepath or an ellipse
if (!link || prev?.type === ParsedType.Text && prev.value.endsWith("/") || link.match(/\.\./)) {