From f1751aff86ee557965176280cbd950725f46bf7a Mon Sep 17 00:00:00 2001 From: Vic Demuzere <65006+sorcix@users.noreply.github.com> Date: Mon, 6 Sep 2021 12:33:38 +0200 Subject: [PATCH] Remove duplicate call LastIndex (#41) --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index fe60be2..b5ac0e8 100644 --- a/main.go +++ b/main.go @@ -67,13 +67,14 @@ func assetDelivery(res http.ResponseWriter, r *http.Request) { assetName = "/index.html" } - if strings.LastIndex(assetName, ".") < 0 { + dot := strings.LastIndex(assetName, ".") + if dot < 0 { // There are no assets with no dot in it http.Error(res, "404 not found", http.StatusNotFound) return } - ext := assetName[strings.LastIndex(assetName, "."):] + ext := assetName[dot:] assetData, err := Asset(path.Join("frontend", assetName)) if err != nil { http.Error(res, "404 not found", http.StatusNotFound)