From 2311d4c70d4a08af35eb7025aef4eece69736a33 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 17 Jul 2018 16:07:50 -0700 Subject: [PATCH] added check for channel request on raw claim url --- server/controllers/assets/serveByClaim/index.js | 10 ++++++++++ .../controllers/assets/utils/determineRequestType.js | 3 +++ 2 files changed, 13 insertions(+) diff --git a/server/controllers/assets/serveByClaim/index.js b/server/controllers/assets/serveByClaim/index.js index 208bc46a..fdabdc96 100644 --- a/server/controllers/assets/serveByClaim/index.js +++ b/server/controllers/assets/serveByClaim/index.js @@ -16,6 +16,16 @@ const { SHOW } = require('../constants/request_types.js'); const serveByClaim = (req, res) => { 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 let hasFileExtension; try { diff --git a/server/controllers/assets/utils/determineRequestType.js b/server/controllers/assets/utils/determineRequestType.js index 4ca2b4ed..e3ee5448 100644 --- a/server/controllers/assets/utils/determineRequestType.js +++ b/server/controllers/assets/utils/determineRequestType.js @@ -8,10 +8,13 @@ function clientWantsAsset ({accept, range}) { } const determineRequestType = (hasFileExtension, headers) => { + logger.debug('hasFileExtension:', hasFileExtension); logger.debug('headers:', headers); if (hasFileExtension || clientWantsAsset(headers)) { + logger.debug('client wants direct asset'); return EMBED; } + logger.debug('client wants show page'); return SHOW; };