aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/routes/announceZBlock/index.js8
-rw-r--r--api/routes/announceZChain/index.js7
-rw-r--r--api/routes/getInnerIPFSContent/index.js9
3 files changed, 13 insertions, 11 deletions
diff --git a/api/routes/announceZBlock/index.js b/api/routes/announceZBlock/index.js
index b395dbf..254e1dc 100644
--- a/api/routes/announceZBlock/index.js
+++ b/api/routes/announceZBlock/index.js
@@ -15,11 +15,11 @@
const getvalidity = require('../../validators/ZblockValidator')
module.exports = (req, res) => {
console.log(req);
- console.log("okay we got called");
- if ( (req.body.zblock) && req.body.zblock.length === 46 ){
+ if ( (req.body.zblock) && typeof req.body.zblock === "string" && req.body.zblock.length === 46 ){
+ let zblock = req.body.zblock;
regex= /Qm[A-Za-z0-9]{44}/;
- if (regex.test(req.body.zblock)){
- getvalidity(req.body.zblock,res);
+ if (regex.test(zblock)){
+ getvalidity(zblock,res);
} else {
res.send({error:"Invalid data"});
}
diff --git a/api/routes/announceZChain/index.js b/api/routes/announceZChain/index.js
index 092b6a9..91ac5b9 100644
--- a/api/routes/announceZChain/index.js
+++ b/api/routes/announceZChain/index.js
@@ -36,10 +36,11 @@ const getNSvalidity = require('../../validators/ZchainValidator')
module.exports = (req, res) => {
console.log(req);
- if ( (req.body.zchain) && req.body.zchain.length === 62 ){//&& req.body.block_signature.length === 46){
+ if ( (req.body.zchain) && typeof req.body.zchain === "string" && req.body.zchain.length === 62 ){
+ let zchain = req.body.zchain;
regex= /k51qzi5uqu5d[A-Za-z0-9]{50}/
- if (regex.test(req.body.zchain)){ // && regex.test(req.body.block_signature)){
- getNSvalidity(req.body.zchain,res);
+ if (regex.test(zchain)){
+ getNSvalidity(zchain,res);
} else {
res.send({error:"Invalid data"});
}
diff --git a/api/routes/getInnerIPFSContent/index.js b/api/routes/getInnerIPFSContent/index.js
index e17d038..b3a05cb 100644
--- a/api/routes/getInnerIPFSContent/index.js
+++ b/api/routes/getInnerIPFSContent/index.js
@@ -15,13 +15,14 @@ function fetchZblock(zblock, res){
};
module.exports = (req, res) => {
console.log(req.query)
- if ( (req.query.ipfs) && req.query.ipfs.length === 46 ){
+ if ( (req.query.ipfs) && typeof req.query.ipfs === "string" && req.query.ipfs.length === 46 ){
+ let ipfs = req.query.ipfs;
regex= /Qm[A-Za-z0-9]{44}/;
- if (regex.test(req.query.ipfs)){
- if (req.query.ipfs === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){
+ if (regex.test(ipfs)){
+ if (ipfs === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){
res.send({error:"Genesis block"});
} else {
- fetchZblock(req.query.ipfs,res);
+ fetchZblock(ipfs,res);
}
} else {
res.send({error:"Invalid data: regexp failed to pass"});