@@ -190,6 +190,30 @@ router.post("/search", function(req, res) { | |||||
var query = req.body.query.toLowerCase(); | 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) { | rpcApi.getRawTransaction(query).then(function(tx) { | ||||
if (tx) { | if (tx) { | ||||
res.redirect("/tx/" + query); | res.redirect("/tx/" + query); | ||||
@@ -40,7 +40,7 @@ html | |||||
a(href="/mempool", class="nav-link") Mempool Info | a(href="/mempool", class="nav-link") Mempool Info | ||||
form(method="post", action="/search", class="form-inline") | form(method="post", action="/search", class="form-inline") | ||||
div(class="input-group") | 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") | span(class="input-group-btn") | ||||
input(type="submit", class="btn btn-primary", value="Search") | input(type="submit", class="btn btn-primary", value="Search") | ||||