serve static assets on urls with file extension #538
2 changed files with 13 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue