From 272c2f1330682680a3c07250a0c91fa7813bd2dc Mon Sep 17 00:00:00 2001 From: Tom Andrade Date: Wed, 18 May 2022 15:12:47 +0200 Subject: [PATCH] feat: do not display port number if it matches protocol default port --- internal/shortie/shortie.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/shortie/shortie.go b/internal/shortie/shortie.go index c2bcc31..c94c9ab 100644 --- a/internal/shortie/shortie.go +++ b/internal/shortie/shortie.go @@ -214,7 +214,12 @@ func Short(t *template.Template) func(ctx *fasthttp.RequestCtx) { }) return } - ru, _ := url.Parse(fmt.Sprintf("%s://%s:%v/%s%s", Proto, Domain, Port, Path, suf)) + var ru *url.URL + if (Proto == "http" && Port == 80) || (Proto == "https" && Port == 443) { + ru, _ = url.Parse(fmt.Sprintf("%s://%s/%s%s", Proto, Domain, Path, suf)) + } else { + ru, _ = url.Parse(fmt.Sprintf("%s://%s:%v/%s%s", Proto, Domain, Port, Path, suf)) + } t.Execute(ctx, body{ IsLink: true, Line1: ru.String(),