diff --git a/routes/baseActionsRouter.js b/routes/baseActionsRouter.js index 51e28ad..12a3233 100755 --- a/routes/baseActionsRouter.js +++ b/routes/baseActionsRouter.js @@ -190,6 +190,30 @@ router.post("/search", function(req, res) { var query = req.body.query.toLowerCase(); + if (query === null || query === "null" || query.length < 1) { + res.redirect("/"); + return; + } + + query = query.replace(/,/g, ""); + + if (query.stringLength < 9) { + if (typeof query == "number") { + res.redirect("/block-height/" + query); + console.log('This is a block'); + return; + } + } + + if (query.stringLength < 36) { + if (typeof query != "number") { + res.redirect("/address/" + query); + console.log('This is not number'); + return; + } + } + + rpcApi.getRawTransaction(query).then(function(tx) { if (tx) { res.redirect("/tx/" + query); diff --git a/views/layout.pug b/views/layout.pug index b6f4c62..0be2d27 100755 --- a/views/layout.pug +++ b/views/layout.pug @@ -40,7 +40,7 @@ html a(href="/mempool", class="nav-link") Mempool Info form(method="post", action="/search", class="form-inline") div(class="input-group") - input(type="text", class="form-control form-control-sm", name="query", placeholder="block height, block hash, txid", style="width: 250px;") + input(type="text", class="form-control form-control-sm", name="query", placeholder="block height, block hash, txid, address", style="width: 250px;") span(class="input-group-btn") input(type="submit", class="btn btn-primary", value="Search")