fixed client wants asset override

This commit is contained in:
bill bittner 2018-07-18 15:33:11 -07:00
parent 1651c24529
commit 651f90cad9
4 changed files with 28 additions and 13 deletions

View file

@ -43,8 +43,10 @@ var createBasicMetaTags = function createBasicMetaTags(_ref) {
}, {
property: 'twitter:title',
content: siteTitle
}, // {property: 'og:url', content: siteHost},
{
}, {
property: 'og:url',
content: siteHost
}, {
property: 'og:site_name',
content: siteTitle
}, {
@ -85,8 +87,10 @@ var createChannelMetaTags = function createChannelMetaTags(_ref2) {
}, {
property: 'twitter:title',
content: "".concat(name, " on ").concat(siteTitle)
}, // {property: 'og:url', content: `${siteHost}/${name}:${longId}`},
{
}, {
property: 'og:url',
content: "".concat(siteHost, "/").concat(name, ":").concat(longId)
}, {
property: 'og:site_name',
content: siteTitle
}, {
@ -131,7 +135,7 @@ var createAssetMetaTags = function createAssetMetaTags(_ref3) {
content: ogTitle
}, {
property: 'og:url',
content: source
content: showUrl
}, {
property: 'og:site_name',
content: siteTitle
@ -232,7 +236,6 @@ var createAssetMetaTags = function createAssetMetaTags(_ref3) {
});
}
console.log('metaTags:', metaTags);
return metaTags;
};

View file

@ -92,7 +92,6 @@ const createAssetMetaTags = ({siteHost, siteTitle, siteTwitter, asset, defaultDe
metaTags.push({property: 'og:type', content: 'article'});
metaTags.push({property: 'twitter:card', content: 'summary_large_image'});
}
console.log('metaTags:', metaTags);
return metaTags;
};

View file

@ -1,3 +1,5 @@
const logger = require('winston');
const { sendGAServeEvent } = require('../../../utils/googleAnalytics');
const handleShowRender = require('../../../render/build/handleShowRender.js');
@ -26,6 +28,17 @@ const serverByIdentifierAndClaim = (req, res) => {
}
// determine request type
let requestType = determineRequestType(hasFileExtension, headers);
/* test logging */
logger.info('serveByIdentifierAndClaim', {
headers,
ip,
originalUrl,
params,
response: requestType,
});
/* end test logging */
if (requestType === SHOW) {
return handleShowRender(req, res);
}

View file

@ -2,19 +2,19 @@ const logger = require('winston');
const { EMBED, SHOW } = require('../constants/request_types.js');
function clientWantsAsset ({accept, range}) {
const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/) && !accept.match(/text\/\*/);
const videoIsWanted = accept && range;
const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/);
const videoIsWanted = accept && accept.match(/video\/.*/) && !accept.match(/text\/html/);
return imageIsWanted || videoIsWanted;
}
const determineRequestType = (hasFileExtension, headers) => {
logger.debug('hasFileExtension:', hasFileExtension);
logger.debug('headers:', headers);
logger.info('determineRequestType', {
hasFileExtension,
headers,
});
if (hasFileExtension || clientWantsAsset(headers)) {
logger.debug('client wants direct asset');
return EMBED;
}
logger.debug('client wants show page');
return SHOW;
};