commit 02627639fdff444abbf1b9072359b14eae39c6fb
parent d9011ec6585b9c3fecee08b8f4c8b7ce88325d2c
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 19 Jan 2023 02:28:22 -0800
simplify regex
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pkg/web/handlers/api/v1/topBarHandler.go b/pkg/web/handlers/api/v1/topBarHandler.go
@@ -778,7 +778,7 @@ func convertLinksWithoutScheme(in string) string {
var linkRgxStr = `(http|ftp|https):\/\/([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?`
var profileRgxStr = `/u/\w{3,20}`
-var linkOrProfileRgx = regexp.MustCompile(`((` + linkRgxStr + `)|(` + profileRgxStr + `))`)
+var linkOrProfileRgx = regexp.MustCompile(`(` + linkRgxStr + `|` + profileRgxStr + `)`)
var userProfileLinkRgx = regexp.MustCompile(`^` + profileRgxStr + `$`)
var youtubeComIDRgx = regexp.MustCompile(`watch\?v=([\w-]+)`)
var youtubeComShosrtsIDRgx = regexp.MustCompile(`/shorts/([\w-]+)`)