From 651f90cad960e7f0acf65608a0a2527671222265 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 18 Jul 2018 15:33:11 -0700 Subject: [PATCH] fixed client wants asset override --- client/build/utils/metaTags.js | 15 +++++++++------ client/src/utils/metaTags.js | 1 - .../assets/serveByIdentifierAndClaim/index.js | 13 +++++++++++++ .../assets/utils/determineRequestType.js | 12 ++++++------ 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/client/build/utils/metaTags.js b/client/build/utils/metaTags.js index 1573eb96..7bcf305e 100644 --- a/client/build/utils/metaTags.js +++ b/client/build/utils/metaTags.js @@ -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; }; diff --git a/client/src/utils/metaTags.js b/client/src/utils/metaTags.js index 909874c0..aad1de30 100644 --- a/client/src/utils/metaTags.js +++ b/client/src/utils/metaTags.js @@ -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; }; diff --git a/server/controllers/assets/serveByIdentifierAndClaim/index.js b/server/controllers/assets/serveByIdentifierAndClaim/index.js index 33dbe82c..b89f5c56 100644 --- a/server/controllers/assets/serveByIdentifierAndClaim/index.js +++ b/server/controllers/assets/serveByIdentifierAndClaim/index.js @@ -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); } diff --git a/server/controllers/assets/utils/determineRequestType.js b/server/controllers/assets/utils/determineRequestType.js index e3ee5448..cd2121ac 100644 --- a/server/controllers/assets/utils/determineRequestType.js +++ b/server/controllers/assets/utils/determineRequestType.js @@ -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; };