diff --git a/routes/index.js b/routes/index.js index 7741e50..06b198a 100644 --- a/routes/index.js +++ b/routes/index.js @@ -3,7 +3,7 @@ var router = express.Router(); var assetLinks = require('../resources/assetlinks.json'); var appleSiteAssociation = require('../resources/apple-app-site-association.json'); -function serverSideRedirect(req, res, next) { +router.get('/', function (req, res, next) { function isAndroid(userAgent) { return userAgent.toLowerCase().indexOf("android") > -1; } @@ -12,25 +12,21 @@ function serverSideRedirect(req, res, next) { return userAgent.toLowerCase().indexOf("iphone") > -1; } - console.log(req.query); - console.log(req.params); - console.log(req.queryParams); - if (req.query.redirect) { - return next(); + return next(); } var userAgent = req.headers['user-agent']; if (isAndroid(userAgent)) { - return res.redirect("https://play.google.com/store/apps/details?id=im.status.ethereum"); + return res.redirect("https://play.google.com/store/apps/details?id=im.status.ethereum"); } else if (isIOS(userAgent)) { - return res.redirect("https://status.im/success") + return res.redirect("https://status.im/success") } return res.redirect("https://status.im") -} +}) router.get('/health', function(req, res) { res.send('OK'); @@ -44,21 +40,21 @@ router.get('/.well-known/apple-app-site-association', function(req, res) { res.json(appleSiteAssociation); }); -router.get('/chat/:chatType/:chatId', serverSideRedirect, function(req, res, next) { +router.get('/chat/:chatType/:chatId', function(req, res, next) { res.render('index', { title: 'Status.im join ' + req.params.chatId + ' chat', path: req.originalUrl }); }); -router.get('/user/:userId', serverSideRedirect, function(req, res, next) { +router.get('/user/:userId', function(req, res, next) { res.render('index', { title: 'Status.im view ' + req.params.userId + ' profile', path: req.originalUrl }); }); -router.get('/browse/:url', serverSideRedirect, function(req, res, next) { +router.get('/browse/:url', function(req, res, next) { res.render('index', { title: 'Status.im browse ' + req.params.url + ' dapp', path: req.originalUrl diff --git a/tests/run.sh b/tests/run.sh index c744a31..1eb0eac 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -17,29 +17,29 @@ shakedown GET /.well-known/apple-app-site-association content_type 'application/json' contains 'im.status.ethereum' -shakedown GET /chat/public/abc?redirect=0 - status 200 - # Android test -shakedown GET /chat/public/abc -H "User-Agent: Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36" +shakedown GET / -H "User-Agent: Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36" header_contains 'Location' 'https://play.google.com/store/apps/details?id=im.status.ethereum' status 302 # IOS -shakedown GET /chat/public/abc -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1" +shakedown GET / -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1" header_contains 'Location' 'https://status.im/success' status 302 # Anything else -shakedown GET /chat/public/abc -H "User-Agent: Unknown" +shakedown GET / -H "User-Agent: Unknown" header_contains 'Location' 'https://status.im' status 302 -shakedown GET /user/blah?redirect=0 +shakedown GET /chat/public/abc status 200 -shakedown GET /browse/www.test.com?redirect=0 +shakedown GET /user/blah + status 200 + +shakedown GET /browse/www.test.com status 200 shakedown GET /health