Fix twitter regexp for comments by removing anchor

This commit is contained in:
ekzyis 2024-09-08 21:46:25 +02:00
parent 6a4892944b
commit 0dd18f210d
1 changed files with 3 additions and 3 deletions

View File

@ -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 != "" {