From 69741dfc1d1748cd6ed97bfaffd579a57fa54287 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Thu, 7 Sep 2017 09:45:00 -0700 Subject: [PATCH] changed file ext vars from '.ext' to 'ext' --- controllers/serveController.js | 6 +++--- routes/serve-routes.js | 12 ++++++------ views/partials/asset.handlebars | 4 ++-- views/partials/assetInfo.handlebars | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/controllers/serveController.js b/controllers/serveController.js index b5e5bb06..4381a788 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -161,10 +161,10 @@ module.exports = { }, serveOrShowAsset (fileInfo, extension, method, headers, originalUrl, ip, res) { // add file extension to the file info - if (extension === '.gifv') { - fileInfo['fileExt'] = '.gifv'; + if (extension === 'gifv') { + fileInfo['fileExt'] = 'gifv'; } else { - fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.')); + fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.') + 1); } // serve or show switch (method) { diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 6937c9a3..12c2184a 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -36,18 +36,18 @@ module.exports = (app) => { let claimId = null; let channelId = null; let method; - let extension; + let fileExtension; // parse the name const positionOfExtension = name.indexOf('.'); if (positionOfExtension >= 0) { - extension = name.substring(positionOfExtension); + fileExtension = name.substring(positionOfExtension + 1); name = name.substring(0, positionOfExtension); /* patch because twitter player preview adds '>' before file extension */ if (name.indexOf('>') >= 0) { name = name.substring(0, name.indexOf('>')); } /* end patch */ - logger.debug('file extension =', extension); + logger.debug('file extension =', fileExtension); if (headers['accept'] && headers['accept'].split(',').includes('text/html')) { method = SHOWLITE; } else { @@ -88,7 +88,7 @@ module.exports = (app) => { if (!fileInfo) { res.status(200).render('noClaims'); } else { - return serveOrShowAsset(fileInfo, extension, method, headers, originalUrl, ip, res); + return serveOrShowAsset(fileInfo, fileExtension, method, headers, originalUrl, ip, res); } }) // 3. update the file @@ -139,7 +139,7 @@ module.exports = (app) => { if (headers['accept'] && headers['accept'].split(',').includes('text/html')) { method = SHOWLITE; } - fileExtension = name.substring(name.indexOf('.')); + fileExtension = name.substring(name.indexOf('.') + 1); name = name.substring(0, name.indexOf('.')); logger.debug('file extension =', fileExtension); } else { @@ -157,7 +157,7 @@ module.exports = (app) => { if (!fileInfo) { res.status(200).render('noClaims'); } else { - return serveOrShowAsset(fileInfo, null, method, headers, originalUrl, ip, res); + return serveOrShowAsset(fileInfo, fileExtension, method, headers, originalUrl, ip, res); } }) // 3. update the database diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 59d4deaa..eb607d24 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -1,8 +1,8 @@
@@ -39,7 +39,7 @@ Markdown
- +
{{/ifConditional}}