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 @@
- + {{#ifConditional fileInfo.fileType '===' 'video/mp4'}} - {{#ifConditional fileInfo.fileExt '===' '.gifv'}} + {{#ifConditional fileInfo.fileExt '===' 'gifv'}} {{!-- link to show route for asset--}} {{!-- html text for embedding asset--}} @@ -26,9 +26,9 @@
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}} - + {{else}} - + {{/ifConditional}}
@@ -39,7 +39,7 @@ Markdown
- +
{{/ifConditional}}