From 73580382f5371cdb5bbbe46da42bd0d50df7e355 Mon Sep 17 00:00:00 2001 From: TheHolyRoger Date: Tue, 21 Jul 2020 19:43:45 +0100 Subject: [PATCH] Add functionality to /block page to use height as well as hash --- routes/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index 665e70dfd..1509aa022 100644 --- a/routes/index.js +++ b/routes/index.js @@ -29,7 +29,18 @@ function route_get_block(res, blockhash) { }); } } else { - route_get_index(res, 'Block not found: ' + blockhash); + if (!isNaN(blockhash)) { + var height = blockhash; + lib.get_blockhash(height, function(hash) { + if (hash != 'There was an error. Check your console.') { + res.redirect('/block/' + hash); + } else { + route_get_index(res, 'Block not found: ' + blockhash); + } + }); + } else { + route_get_index(res, 'Block not found: ' + blockhash); + } } }); }