Merge pull request #820 from jessopb/fourohfour2

Sets proper 404 status in most cases
This commit is contained in:
Shawn K 2018-12-14 01:51:22 -06:00 committed by GitHub
commit fedea718b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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