From c2d927788a683af2e5eb3d403c963a971d120a54 Mon Sep 17 00:00:00 2001 From: dan Date: Sun, 29 Mar 2020 15:36:52 -0600 Subject: [PATCH] update other share option --- Server/src/routes/api/share.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Server/src/routes/api/share.js b/Server/src/routes/api/share.js index b122400..c60b60c 100644 --- a/Server/src/routes/api/share.js +++ b/Server/src/routes/api/share.js @@ -25,12 +25,13 @@ router.get("/:shareCode",function(req,res){ case "e": return getEvent(req,res,param); case "o": - return getOther(req, res) + return getOther(req, res, param) } }); -function getOther(req, res,) { - console.log(req.headers); +function getOther(req, res, param) { + param = decodeURIComponent(param); + var params = JSON.parse(param); var userAgent = req.headers['user-agent']; var userAgentOverride = req.headers['user-agent-override']; var referrer = req.headers['referer'] || ""; @@ -39,9 +40,9 @@ function getOther(req, res,) { userAgent === 'Facebot' || userAgent.startsWith('Twitterbot') || referrer.startsWith('http://opengraphcheck.com')) { - getOtherMeta(req, res, req.query.title, req.query.description, req.query.imageUrl, req.query.imageWidth, req.query.imageHeight, req.query.url); + getOtherMeta(req, res, params.title, params.description, params.imageUrl, params.imageWidth, params.imageHeight, params.url); } else { - var url = req.query.url; + var url = params.url || (req.protocol + "://" + req.hostname); res.redirect(url); } } @@ -64,6 +65,8 @@ function getSermon(req, res, id){ } function getOtherMeta(req, res, title, description, imageUrl, imageWidth, imageHeight, url) { + imageWidth = imageWidth || 200; + imageHeight = imageHeight || 200; var result = ` Old Fashion Baptist Church @@ -74,8 +77,8 @@ function getOtherMeta(req, res, title, description, imageUrl, imageWidth, imageH - - + +