mirror of
https://github.com/GOSTSec/gostexplr
synced 2025-01-30 08:24:23 +00:00
Detect by search string length what to search for
This commit is contained in:
parent
68d2778434
commit
33d9bd112c
@ -26,38 +26,41 @@ router.post('/', async function(req, res, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// looking for address
|
if (search.length === 34) {
|
||||||
const address = await models.Address.findOne({
|
// looking for address
|
||||||
where: {
|
const address = await models.Address.findOne({
|
||||||
address: search,
|
where: {
|
||||||
},
|
address: search,
|
||||||
});
|
},
|
||||||
if (address) {
|
});
|
||||||
res.redirect(`/address/${address.address}/`);
|
if (address) {
|
||||||
return;
|
res.redirect(`/address/${address.address}/`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if(search.length === 64) {
|
||||||
|
// looking for transaction
|
||||||
|
const transaction = await models.Transaction.findOne({
|
||||||
|
where: {
|
||||||
|
txid: search,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (transaction) {
|
||||||
|
res.redirect(`/transaction/${transaction.txid}/`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// looking for block
|
||||||
|
const block = await models.Block.findOne({
|
||||||
|
where: {
|
||||||
|
hash: search,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (block) {
|
||||||
|
res.redirect(`/block/${block.hash}/`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// looking for transaction
|
|
||||||
const transaction = await models.Transaction.findOne({
|
|
||||||
where: {
|
|
||||||
txid: search,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (transaction) {
|
|
||||||
res.redirect(`/transaction/${transaction.txid}/`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// looking for block
|
|
||||||
const block = await models.Block.findOne({
|
|
||||||
where: {
|
|
||||||
hash: search,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (block) {
|
|
||||||
res.redirect(`/block/${block.hash}/`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
res.status(404).render('404');
|
res.status(404).render('404');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user