Merge pull request #723 from lbryio/render-canonical-fix
return null if either requestId or requestType are undefined
This commit is contained in:
commit
4b878222e7
2 changed files with 11 additions and 0 deletions
|
@ -44,6 +44,10 @@ var getCanonicalUrlFromShow = function getCanonicalUrlFromShow(show) {
|
|||
var requestId = show.requestList[show.request.id];
|
||||
var requestType = show.request.type;
|
||||
|
||||
if (!requestId || !requestType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (requestType) {
|
||||
case 'ASSET_DETAILS':
|
||||
var asset = show.assetList[requestId.key];
|
||||
|
|
|
@ -20,6 +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];
|
||||
|
@ -36,6 +41,7 @@ const returnSagaWithParams = (saga, params) => {
|
|||
yield call(saga, params);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = (req, res) => {
|
||||
let context = {};
|
||||
|
||||
|
@ -51,6 +57,7 @@ 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 {
|
||||
|
|
Loading…
Reference in a new issue