From ad9ab8a0e25be5bf48ea08df9653f42d9c313b88 Mon Sep 17 00:00:00 2001 From: Myles <96409608+ice-myles@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:44:11 +0300 Subject: [PATCH] Remove https://x.com or https://twitter.com prefix from location header. (#184) Remove https://x.com or https://twitter.com prefix from location header. --- kyc/social/internal/twitter.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kyc/social/internal/twitter.go b/kyc/social/internal/twitter.go index da906def..10a112e0 100644 --- a/kyc/social/internal/twitter.go +++ b/kyc/social/internal/twitter.go @@ -43,6 +43,12 @@ func (t *twitterVerifierImpl) VerifyPostLinkOf(ctx context.Context, target, expe if strings.HasPrefix(target, "https://t.co") { loc, err := t.Scraper.Fetcher().Head(ctx, target) + if strings.HasPrefix(loc, "https://twitter.com") { + loc = strings.Replace(loc, "https://twitter.com", "", 1) + } + if strings.HasPrefix(loc, "https://x.com") { + loc = strings.Replace(loc, "https://x.com", "", 1) + } if err != nil { log.Warn("twitter: failed to fetch location header", "error", err) // Fallthrough.