From 0dd18f210d8db5fd6362167d1da5ad7a57f286af Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 8 Sep 2024 21:46:25 +0200 Subject: [PATCH] Fix twitter regexp for comments by removing anchor --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 25c4759..1ef692a 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ type NostrClient struct { } var ( - TwitterUrlRegexp = regexp.MustCompile(`^(?:https?:\/\/)?((www\.)?(twitter|x)\.com)\/`) + TwitterUrlRegexp = regexp.MustCompile(`(?:https?:\/\/)?(?:www\.)?((?:twitter|x)\.com)\/\w+\/status(?:es)?\/\d+`) // references: // - https://github.com/zedeus/nitter/wiki/Instances // - https://status.d420.de/ @@ -57,9 +57,9 @@ func main() { var comment string if m = TwitterUrlRegexp.FindStringSubmatch(item.Url); m != nil { - comment = strings.Replace(item.Url, m[1], "xcancel.com", 1) + comment = strings.Replace(m[0], m[1], "xcancel.com", 1) } else if m = TwitterUrlRegexp.FindStringSubmatch(item.Text); m != nil { - comment = strings.Replace(item.Text, m[1], "xcancel.com", 1) + comment = strings.Replace(m[0], m[1], "xcancel.com", 1) } if comment != "" {