From 05f8084089c0a273fc120c688100d21ebd72e5e1 Mon Sep 17 00:00:00 2001 From: Seednode Date: Wed, 6 Sep 2023 11:53:19 -0500 Subject: [PATCH] Removed unused Stat type, removed unused regex for durations, replaced strings.Builder with string constant for favicon html --- cmd/root.go | 2 +- cmd/web.go | 38 ++++++++++++++------------------------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index aca4626..6ba4652 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,7 @@ var ( ) const ( - Version string = "0.57.3" + Version string = "0.57.4" ) var ( diff --git a/cmd/web.go b/cmd/web.go index 8996d2f..af38940 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -44,14 +44,19 @@ const ( ImagePrefix string = `/view` RedirectStatusCode int = http.StatusSeeOther Timeout time.Duration = 10 * time.Second -) -type Stat int + FaviconHtml string = ` + + + + + + ` +) type Regexes struct { alphanumeric *regexp.Regexp filename *regexp.Regexp - units *regexp.Regexp } type Filters struct { @@ -340,25 +345,11 @@ type timesServed struct { Times []string } -func addFavicon() string { - var htmlBody strings.Builder - - htmlBody.WriteString(``) - htmlBody.WriteString(``) - htmlBody.WriteString(``) - htmlBody.WriteString(``) - htmlBody.WriteString(``) - htmlBody.WriteString(``) - htmlBody.WriteString(``) - - return htmlBody.String() -} - func newErrorPage(title, body string) string { var htmlBody strings.Builder htmlBody.WriteString(``) - htmlBody.WriteString(addFavicon()) + htmlBody.WriteString(FaviconHtml) htmlBody.WriteString(``) htmlBody.WriteString(fmt.Sprintf("%s", title)) htmlBody.WriteString(fmt.Sprintf("%s", body)) @@ -409,7 +400,7 @@ func serverErrorHandler() func(http.ResponseWriter, *http.Request, interface{}) return serverError } -func RefreshInterval(r *http.Request, Regexes *Regexes) (int64, string) { +func RefreshInterval(r *http.Request) (int64, string) { var interval string if refreshInterval == "" { @@ -618,7 +609,7 @@ func serveDebugHtml(args []string, index *Index) httprouter.Handle { var htmlBody strings.Builder htmlBody.WriteString(``) - htmlBody.WriteString(addFavicon()) + htmlBody.WriteString(FaviconHtml) htmlBody.WriteString(``) htmlBody.WriteString(fmt.Sprintf("Index contains %s files", fileCount)) @@ -776,7 +767,7 @@ func serveRoot(paths []string, Regexes *Regexes, index *Index) httprouter.Handle sortOrder := SortOrder(r) - _, refreshInterval := RefreshInterval(r, Regexes) + _, refreshInterval := RefreshInterval(r) var filePath string @@ -890,13 +881,13 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl w.Header().Add("Content-Type", "text/html") - refreshTimer, refreshInterval := RefreshInterval(r, Regexes) + refreshTimer, refreshInterval := RefreshInterval(r) queryParams := generateQueryParams(filters, sortOrder, refreshInterval) var htmlBody strings.Builder htmlBody.WriteString(``) - htmlBody.WriteString(addFavicon()) + htmlBody.WriteString(FaviconHtml) htmlBody.WriteString(`