Skip to content

Commit

Permalink
Merge pull request #134 from internetarchive/telegram-url
Browse files Browse the repository at this point in the history
fix: recursion present in Telegram URLs
  • Loading branch information
CorentinB authored Aug 20, 2024
2 parents 764b35c + 4c2c5ef commit be08a01
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/pkg/crawl/sitespecific/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func IsTelegramEmbedURL(url string) bool {
return strings.Contains(url, "/t.me/") && strings.Contains(url, "?embed=1")
return strings.Contains(url, "/t.me/") && strings.Contains(url, "embed=1")
}

func IsTelegramURL(url string) bool {
Expand All @@ -15,9 +15,8 @@ func IsTelegramURL(url string) bool {

func TransformURL(URL *url.URL) {
// Add embed=1 to the URL, without changing the original URL
if len(URL.RawQuery) > 0 {
URL.RawQuery += "&embed=1&mode=tme"
} else {
URL.RawQuery = "embed=1&mode=tme"
}
q := URL.Query()
q.Add("embed", "1")
q.Add("mode", "tme")
URL.RawQuery = q.Encode()
}

0 comments on commit be08a01

Please sign in to comment.