small pixel drawing of a pufferfish vore

do our best to trim the domain str
Jes Olson j3s@c3f.net
Mon, 20 Mar 2023 21:49:32 -0700
commit

3a640a8f4f60de59e17964dcc4d3528e8a493546

parent

28d1c80865e6767cb85d230cd4382b0bb03ee643

1 files changed, 7 insertions(+), 3 deletions(-)

jump to
M site.gosite.go

@@ -307,10 +307,14 @@ // prints the base domain, otherwise returning the

// unmodified string func (s *Site) printDomain(rawURL string) string { parsedURL, err := url.Parse(rawURL) - if err != nil { - return "" + if err == nil { + return parsedURL.Hostname() } - return parsedURL.Hostname() + // do our best to trim it manually if url parsing fails + trimmedStr := strings.TrimPrefix(rawURL, "http://") + trimmedStr = strings.TrimPrefix(trimmedStr, "https://") + + return strings.Split(trimmedStr, "/")[0] } // renderErr sets the correct http status in the header,