diff --git a/ghost/mw-api-version-mismatch/lib/mw-api-version-mismatch.js b/ghost/mw-api-version-mismatch/lib/mw-api-version-mismatch.js index 021cee1aae..4a4c5eaae4 100644 --- a/ghost/mw-api-version-mismatch/lib/mw-api-version-mismatch.js +++ b/ghost/mw-api-version-mismatch/lib/mw-api-version-mismatch.js @@ -5,7 +5,7 @@ const versionMismatchHandler = (APIVersionCompatibilityService) => { await APIVersionCompatibilityService.handleMismatch({ acceptVersion: req.headers['accept-version'], contentVersion: `v${res.locals.safeVersion}`, - requestURL: req.originalURL, + requestURL: req.originalUrl, userAgent: req.headers['user-agent'] }); } diff --git a/ghost/mw-api-version-mismatch/test/mw-api-version-mismatch.test.js b/ghost/mw-api-version-mismatch/test/mw-api-version-mismatch.test.js index 97f771e563..cfa54d4047 100644 --- a/ghost/mw-api-version-mismatch/test/mw-api-version-mismatch.test.js +++ b/ghost/mw-api-version-mismatch/test/mw-api-version-mismatch.test.js @@ -10,16 +10,27 @@ describe('mw-api-version-mismatch', function () { handleMismatch: sinon.stub().resolves() }; const req = { - headers: {} + originalUrl: '/api/admin/posts/1', + headers: { + 'accept-version': 'v3.28', + 'user-agent': 'Zapier/2.1 GhostAdminSDK/3.28' + } }; const res = { - locals: {} + locals: { + safeVersion: '4.46' + } }; versionMismatchMW(APIVersionCompatibilityService)(new errors.RequestNotAcceptableError({ code: 'UPDATE_CLIENT' }), req, res, () => { assert.equal(APIVersionCompatibilityService.handleMismatch.called, true); + assert.equal(APIVersionCompatibilityService.handleMismatch.args[0][0].acceptVersion, 'v3.28'); + assert.equal(APIVersionCompatibilityService.handleMismatch.args[0][0].contentVersion, 'v4.46'); + assert.equal(APIVersionCompatibilityService.handleMismatch.args[0][0].requestURL, '/api/admin/posts/1'); + assert.equal(APIVersionCompatibilityService.handleMismatch.args[0][0].userAgent, 'Zapier/2.1 GhostAdminSDK/3.28'); + done(); }); });