From 89788176349501074d09d8eb448e7c553410c103 Mon Sep 17 00:00:00 2001 From: Odyssey Date: Tue, 29 Nov 2022 21:03:05 +0100 Subject: [PATCH] Remove http:// and https:// Signed-off-by: Odyssey --- pages/user.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pages/user.go b/pages/user.go index db68f4a..d636769 100644 --- a/pages/user.go +++ b/pages/user.go @@ -79,6 +79,21 @@ func HandleUser(c *fiber.Ctx) error { // Trust Nobody readmeOutput := UGCPolicy().SanitizeBytes(mightBeUnsafe) + var link string + + if user.Get("blog").String() == "" { + link = "" + } else { + link = user.Get("blog").String() + if strings.HasPrefix(link, "https://") { + link = strings.TrimPrefix(link, "https://") + } else if strings.HasPrefix(link, "http://") { + link = strings.TrimPrefix(link, "http://") + } else { + log.Println("Has no prefix") + } + } + userArray = append(userArray, User{ Login: user.Get("login").String(), Name: user.Get("name").String(), @@ -87,7 +102,7 @@ func HandleUser(c *fiber.Ctx) error { Location: user.Get("location").String(), Following: user.Get("following").Int(), Followers: user.Get("followers").Int(), - Link: user.Get("blog").String(), + Link: link, Company: user.Get("company").String(), Type: user.Get("type").String(), EwTwitter: user.Get("twitter_username").String(),