From c6f9351149c2ba48f9a38a27565962724c1d22e4 Mon Sep 17 00:00:00 2001 From: Alexander Sheiko Date: Mon, 10 Aug 2020 14:08:35 +0300 Subject: [PATCH] Extended user validity check --- profile.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/profile.go b/profile.go index 2c6daa2..100434d 100644 --- a/profile.go +++ b/profile.go @@ -55,15 +55,17 @@ func GetProfile(username string) (Profile, error) { return Profile{}, err } - // parse location, also check is username valid + // parse location location := strings.TrimSpace(doc.Find(".ProfileHeaderCard-locationText.u-dir").First().Text()) - if location == "" { - return Profile{}, fmt.Errorf("either @%s does not exist or is private", username) - } // parse join date text joined, _ := time.Parse("3:4 PM - 2 Jan 2006", doc.Find(".ProfileHeaderCard-joinDateText.u-dir").First().AttrOr("title", "")) + // check is username valid + if location == "" && joined.IsZero() { + return Profile{}, fmt.Errorf("either @%s does not exist or is private", username) + } + return Profile{ Avatar: doc.Find(".ProfileAvatar-image").First().AttrOr("src", ""), Banner: doc.Find(".ProfileCanopy-headerBg img").First().AttrOr("src", ""),