Piotr Czajkowski 1 year ago
parent
commit
36b02e9e28
1 changed files with 4 additions and 5 deletions
  1. 4 5
      server.go

+ 4 - 5
server.go

@@ -66,16 +66,15 @@ func decode(w http.ResponseWriter, r *http.Request) {
 func redirectOrServe(w http.ResponseWriter, r *http.Request) {
 	linkID := strings.TrimPrefix(r.URL.Path, "/")
 
-	if linkID == "" {
-		http.ServeFile(w, r, indexHTML)
-	} else {
+	if linkID != "" {
 		link := getLink(linkID)
 		if link != "" {
 			http.Redirect(w, r, link, http.StatusMovedPermanently)
-		} else {
-			http.ServeFile(w, r, indexHTML)
+			return
 		}
 	}
+
+	http.ServeFile(w, r, indexHTML)
 }
 
 func main() {