From d38d8f106138b7fbd4df9e026c944c397adc5a39 Mon Sep 17 00:00:00 2001 From: jessop Date: Thu, 13 Dec 2018 22:43:03 -0500 Subject: [PATCH] Sets proper 404 status in most cases --- server/render/src/handleShowRender.jsx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/server/render/src/handleShowRender.jsx b/server/render/src/handleShowRender.jsx index 6e527b0c..b306ae5f 100644 --- a/server/render/src/handleShowRender.jsx +++ b/server/render/src/handleShowRender.jsx @@ -20,11 +20,11 @@ const createCanonicalLink = require('../../../utils/createCanonicalLink'); const getCanonicalUrlFromShow = show => { const requestId = show.requestList[show.request.id]; const requestType = show.request.type; - + if (!requestId || !requestType) { return null; } - + switch (requestType) { case 'ASSET_DETAILS': const asset = show.assetList[requestId.key]; @@ -57,16 +57,15 @@ module.exports = (req, res) => { // Workaround, remove when a solution for async httpContext exists const showState = store.getState().show; const assetKeys = Object.keys(showState.assetList); - - if(assetKeys.length !== 0) { - res.claimId = showState.assetList[assetKeys[0]].claimId; - } else { - const channelKeys = Object.keys(showState.channelList); + const channelKeys = Object.keys(showState.channelList); - if(channelKeys.length !== 0) { - res.claimId = showState.channelList[channelKeys[0]].longId; - res.isChannel = true; - } + if (assetKeys.length !== 0) { + res.claimId = showState.assetList[assetKeys[0]].claimId; + } else if (channelKeys.length !== 0) { + res.claimId = showState.channelList[channelKeys[0]].longId; + res.isChannel = true; + } else { + res.status(404); } // render component to a string