From 2f341dc998d688941529c81c662b6a2d6c09dc32 Mon Sep 17 00:00:00 2001 From: Raghav Sood Date: Sat, 15 Jun 2024 21:00:14 +0800 Subject: [PATCH] webui/search: case insensitive search --- webui/search.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webui/search.go b/webui/search.go index 99dcafd..19758cc 100644 --- a/webui/search.go +++ b/webui/search.go @@ -3,6 +3,7 @@ package webui import ( "fmt" "net/http" + "strings" "github.com/RaghavSood/btcsupply/address" "github.com/RaghavSood/btcsupply/templates" @@ -12,23 +13,24 @@ import ( func (w *WebUI) Search(c *gin.Context) { q := c.Query("q") + lowerQ := strings.ToLower(q) // Check if query is a block number or hash - block, err := w.db.GetBlock(q) + block, err := w.db.GetBlock(lowerQ) if err == nil { c.Redirect(302, fmt.Sprintf("/block/%d", block.BlockHeight)) return } // Check if query is a transaction ID - tx, err := w.db.GetTransaction(q) + tx, err := w.db.GetTransaction(lowerQ) if err == nil { c.Redirect(302, fmt.Sprintf("/transaction/%s", tx.TxID)) return } // Check if query is a script - burnScript, err := w.db.GetBurnScript(q) + burnScript, err := w.db.GetBurnScript(lowerQ) if err == nil { c.Redirect(302, fmt.Sprintf("/script/%s", burnScript.Script)) return