Merge pull request #34 from utopia-os/mail-regex-fix

fix(other): updated regex for mail detection
This commit is contained in:
antontranelis 2024-11-11 14:43:43 +01:00 committed by GitHub
commit 693f2c6d38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
export const urlRegex = export const urlRegex =
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
/(^| )(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,10}(:[0-9]{1,10})?(\/.*)?$/gm /(^| )(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,10}(:[0-9]{1,10})?(\/.*)?$/gm
export const mailRegex = /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi export const mailRegex = /(?<![[(])([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})(?![\])])/gi
export function fixUrls(message: string): string { export function fixUrls(message: string): string {
message = message.replace(urlRegex, function (url) { message = message.replace(urlRegex, function (url) {