Merge pull request #723 from lbryio/render-canonical-fix

return null if either requestId or requestType are undefined
This commit is contained in:
Shawn K 2018-11-12 11:20:16 -05:00 committed by GitHub
commit 4b878222e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

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

View file

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