fix: twitter plugin replacement logic
This commit is contained in:
parent
3b09a9dd47
commit
368c45cd13
1 changed files with 2 additions and 7 deletions
|
@ -54,17 +54,12 @@ func (p *TwitterExpander) OnMessage(msg *model.Message, config map[string]interf
|
|||
// Parse the URL
|
||||
parsedURL, err := url.Parse(link)
|
||||
if err != nil {
|
||||
// If parsing fails, just do the simple replacement
|
||||
link = strings.Replace(link, "twitter.com", replacementDomain, 1)
|
||||
link = strings.Replace(link, "x.com", replacementDomain, 1)
|
||||
return link
|
||||
}
|
||||
|
||||
// Change the host to the configured domain
|
||||
if strings.Contains(parsedURL.Host, "twitter.com") {
|
||||
parsedURL.Host = strings.Replace(parsedURL.Host, "twitter.com", replacementDomain, 1)
|
||||
} else if strings.Contains(parsedURL.Host, "x.com") {
|
||||
parsedURL.Host = strings.Replace(parsedURL.Host, "x.com", replacementDomain, 1)
|
||||
if strings.Contains(parsedURL.Host, "twitter.com") || strings.Contains(parsedURL.Host, "x.com") {
|
||||
parsedURL.Host = replacementDomain
|
||||
}
|
||||
|
||||
// Remove query parameters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue