From 399883b04ce766ed9cd00bca9acf001e3c175ce9 Mon Sep 17 00:00:00 2001 From: joeuhren <46763106+joeuhren@users.noreply.github.com> Date: Mon, 23 Nov 2020 20:20:58 -0700 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 f7abd87..1e35788 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); + } } }); }