From 2a9fca6427ac91d75d8630eaa66440d350e49678 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Wed, 11 May 2022 10:35:00 +0100 Subject: [PATCH] Removed support for mixed http/https mode refs: https://github.com/TryGhost/Ghost/issues/14446 - currently ghost will upgrade configured urls to https if a secure request comes into a http configured site - we no longer want to support this feature - instead, ghost will strictly honour the configured URL --- ghost/config-url-helpers/lib/config-url-helpers.js | 7 +------ ghost/config-url-helpers/test/config-url-helpers.test.js | 6 ------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/ghost/config-url-helpers/lib/config-url-helpers.js b/ghost/config-url-helpers/lib/config-url-helpers.js index 5a4b8fb40e..1c4311a825 100644 --- a/ghost/config-url-helpers/lib/config-url-helpers.js +++ b/ghost/config-url-helpers/lib/config-url-helpers.js @@ -27,16 +27,11 @@ function getSubdir() { * Imagine Ghost runs with http, but nginx allows SSL connections. * * @callback getSiteUrlFn - * @param {boolean} [secure] optionally force the url to be secure * @return {string} returns the url as defined in config, but always with a trailing `/` */ -function getSiteUrl(secure = false) { +function getSiteUrl() { let siteUrl = this.get('url'); - if (secure) { - siteUrl = siteUrl.replace('http://', 'https://'); - } - if (!siteUrl.match(/\/$/)) { siteUrl += '/'; } diff --git a/ghost/config-url-helpers/test/config-url-helpers.test.js b/ghost/config-url-helpers/test/config-url-helpers.test.js index 70bd7378c8..8c9fdf17c0 100644 --- a/ghost/config-url-helpers/test/config-url-helpers.test.js +++ b/ghost/config-url-helpers/test/config-url-helpers.test.js @@ -72,12 +72,6 @@ describe('Config URL Helpers', function () { nconf.getSiteUrl().should.eql('http://example.com/'); }); - - it('returns https if secure=true', function () { - fakeConfig.url = 'http://example.com/'; - - nconf.getSiteUrl(true).should.eql('https://example.com/'); - }); }); describe('getAdminUrl', function () {