diff --git a/packages/indiekit/lib/middleware/locals.js b/packages/indiekit/lib/middleware/locals.js index 5fe900b8f..842278351 100644 --- a/packages/indiekit/lib/middleware/locals.js +++ b/packages/indiekit/lib/middleware/locals.js @@ -1,5 +1,4 @@ import {getNavigation} from '../navigation.js'; -import {getMediaEndpoint} from '../publication.js'; /** * Expose config to frontend templates @@ -19,7 +18,6 @@ export const locals = indiekitConfig => { response.locals.application = application; // Publication - publication.mediaEndpoint = getMediaEndpoint(publication, request); response.locals.publication = publication; // Session diff --git a/packages/indiekit/lib/publication.js b/packages/indiekit/lib/publication.js index 728583cce..594eb8241 100644 --- a/packages/indiekit/lib/publication.js +++ b/packages/indiekit/lib/publication.js @@ -63,20 +63,3 @@ export const getPostTypes = publication => { return []; }; - -/** - * Get media endpoint from server derived values - * - * @param {object} publication Publication configuration - * @param {object} request HTTP request - * @returns {string} Media endpoint URL - */ -export const getMediaEndpoint = (publication, request) => { - const {mediaEndpoint} = publication; - - if (mediaEndpoint && isUrl(mediaEndpoint)) { - return mediaEndpoint; - } - - return `${request.protocol}://${request.headers.host}${mediaEndpoint}`; -}; diff --git a/packages/indiekit/tests/lib/publication.js b/packages/indiekit/tests/lib/publication.js index 0f48cb542..aa7764a2a 100644 --- a/packages/indiekit/tests/lib/publication.js +++ b/packages/indiekit/tests/lib/publication.js @@ -6,7 +6,6 @@ import {mongodbConfig} from '../../config/mongodb.js'; import {Cache} from '../../lib/cache.js'; import { getCategories, - getMediaEndpoint, getPostTemplate, getPostTypes } from '../../lib/publication.js'; @@ -134,30 +133,3 @@ test('Merges values from custom and preset post types', t => { test('Returns array if no preset or custom post types', t => { t.deepEqual(getPostTypes({}), []); }); - -test('Gets media endpoint from server derived values', t => { - const request = { - protocol: 'https', - headers: { - host: 'server.example' - } - }; - - const result = getMediaEndpoint(t.context.publication, request); - - t.is(result, 'https://server.example/media'); -}); - -test('Gets media endpoint from publication configuration', t => { - const publication = {mediaEndpoint: 'https://website.example/media'}; - const request = { - protocol: 'https', - headers: { - host: 'website.example' - } - }; - - const result = getMediaEndpoint(publication, request); - - t.is(result, 'https://website.example/media'); -});