From 1aa7e368a2f9da22ba764fccfe45f9ef14d4c0a7 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 24 Jul 2019 11:12:07 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Added=20`url`=20value=20to=20the?= =?UTF-8?q?=20Content=20API=20/settings/=20endpoint=20(#10946)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes https://github.com/TryGhost/Ghost/issues/10945 - adds the `url` property to the returned output manually because it's a config value rather than a settings value --- core/server/api/v2/settings-public.js | 5 ++++- core/test/acceptance/old/content/settings_spec.js | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/server/api/v2/settings-public.js b/core/server/api/v2/settings-public.js index 1ca2e6a9a4..79c413527e 100644 --- a/core/server/api/v2/settings-public.js +++ b/core/server/api/v2/settings-public.js @@ -1,4 +1,5 @@ const settingsCache = require('../../services/settings/cache'); +const urlUtils = require('../../lib/url-utils'); module.exports = { docName: 'settings', @@ -8,7 +9,9 @@ module.exports = { query() { // @TODO: decouple settings cache from API knowledge // The controller fetches models (or cached models) and the API frame for the target API version formats the response. - return settingsCache.getPublic(); + return Object.assign({}, settingsCache.getPublic(), { + url: urlUtils.urlFor('home', true) + }); } } }; diff --git a/core/test/acceptance/old/content/settings_spec.js b/core/test/acceptance/old/content/settings_spec.js index b1dee37029..9c8505b26f 100644 --- a/core/test/acceptance/old/content/settings_spec.js +++ b/core/test/acceptance/old/content/settings_spec.js @@ -43,7 +43,7 @@ describe('Settings Content API', function () { // Verify we have the right keys for settings settings.should.have.properties(_.values(publicSettings)); - Object.keys(settings).length.should.equal(22); + Object.keys(settings).length.should.equal(23); // Verify that we are returning the defaults for each value _.forEach(settings, (value, key) => { @@ -60,6 +60,12 @@ describe('Settings Content API', function () { return; } + // `url` does not come from the settings cache + if (key === 'url') { + should(value).eql(`${config.get('url')}/`); + return; + } + let defaultKey = _.findKey(publicSettings, v => v === key); let defaultValue = _.find(defaultSettings, setting => setting.key === defaultKey).defaultValue;