From dbdf7160bfb82491b53c09e126c68efdacd6bcb4 Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 13 Oct 2021 10:04:49 +0200 Subject: [PATCH] Simplified DynamicRedirectManager's constructor refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch - This simplification allows to make the test for dependent services a lot more readable without a need to stub urlUtils --- core/server/services/offers/service.js | 7 +++++-- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/server/services/offers/service.js b/core/server/services/offers/service.js index cbcc59cd0b..9e02027632 100644 --- a/core/server/services/offers/service.js +++ b/core/server/services/offers/service.js @@ -11,8 +11,11 @@ const urlUtils = require('../../../shared/url-utils'); const models = require('../../models'); const redirectManager = new DynamicRedirectManager({ - permanentMaxAge: config.get('caching:customRedirects:maxAge') -}, urlUtils); + permanentMaxAge: config.get('caching:customRedirects:maxAge'), + getSubdirectoryURL: (pathname) => { + return urlUtils.urlJoin(urlUtils.getSubdir(), pathname); + } +}); module.exports = { async init() { diff --git a/package.json b/package.json index 2764814de6..38c52724bd 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@tryghost/email-analytics-provider-mailgun": "1.0.3", "@tryghost/email-analytics-service": "1.0.2", "@tryghost/errors": "0.2.16", - "@tryghost/express-dynamic-redirects": "0.1.0", + "@tryghost/express-dynamic-redirects": "0.2.0", "@tryghost/helpers": "1.1.52", "@tryghost/image-transform": "1.0.16", "@tryghost/job-manager": "0.8.10", diff --git a/yarn.lock b/yarn.lock index 1f670ecd6f..5617d534d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1325,10 +1325,10 @@ "@tryghost/ignition-errors" "^0.1.0" lodash "^4.17.21" -"@tryghost/express-dynamic-redirects@0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@tryghost/express-dynamic-redirects/-/express-dynamic-redirects-0.1.0.tgz#85c6caa2887034ea8064a40ca0622a87e4000c4e" - integrity sha512-C9594LRjH3wsAWUoMCb5sZg/1Ifrn/O2aQeWQeBDgqUWAScmtUuIpkPNTRrq0cZ1Yv4ig5gWMKv4YSe5TdAVdA== +"@tryghost/express-dynamic-redirects@0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@tryghost/express-dynamic-redirects/-/express-dynamic-redirects-0.2.0.tgz#a5bafcc068c14c353ba072b450be0193d504e506" + integrity sha512-ABlt58j1Lhl3tZdNlOD9wXORHeURWG0Hq5vBIrL9Fp+hyzBS3k8HeMQl4maSwudpY8WqBUjp2IUJfRO0onMVbw== "@tryghost/helpers@1.1.52": version "1.1.52"