serve static assets on urls with file extension #538

Merged
bones7242 merged 19 commits from 515-showlite-serves-asset into master 2018-07-20 18:57:12 +02:00
2 changed files with 13 additions and 0 deletions
Showing only changes of commit 2311d4c70d - Show all commits

View file

@ -16,6 +16,16 @@ const { SHOW } = require('../constants/request_types.js');
const serveByClaim = (req, res) => { const serveByClaim = (req, res) => {
const { headers, ip, originalUrl, params } = req; const { headers, ip, originalUrl, params } = req;
// return early if channel request
let isChannel = false;
try {
({ isChannel } = lbryUri.parseIdentifier(params.claim));
} catch (error) {
return res.status(400).json({success: false, message: error.message});
}
if (isChannel) {
return handleShowRender(req, res);
}
// decide if this is a show request // decide if this is a show request
let hasFileExtension; let hasFileExtension;
try { try {

View file

@ -8,10 +8,13 @@ function clientWantsAsset ({accept, range}) {
} }
const determineRequestType = (hasFileExtension, headers) => { const determineRequestType = (hasFileExtension, headers) => {
logger.debug('hasFileExtension:', hasFileExtension);
logger.debug('headers:', headers); logger.debug('headers:', headers);
if (hasFileExtension || clientWantsAsset(headers)) { if (hasFileExtension || clientWantsAsset(headers)) {
logger.debug('client wants direct asset');
return EMBED; return EMBED;
} }
logger.debug('client wants show page');
return SHOW; return SHOW;
}; };