diff --git a/core/server/api/canary/utils/serializers/output/redirects.js b/core/server/api/canary/utils/serializers/output/redirects.js index 7331b5184f..1f9b19e589 100644 --- a/core/server/api/canary/utils/serializers/output/redirects.js +++ b/core/server/api/canary/utils/serializers/output/redirects.js @@ -1,5 +1,5 @@ module.exports = { - download(response, apiConfig, frame) { + all(response, apiConfig, frame) { frame.response = response; } }; diff --git a/test/e2e-api/admin/redirects.test.js b/test/e2e-api/admin/redirects.test.js index 35412cb5b8..917f255470 100644 --- a/test/e2e-api/admin/redirects.test.js +++ b/test/e2e-api/admin/redirects.test.js @@ -20,7 +20,29 @@ describe('Redirects API', function () { .set('Origin', config.get('url')) .expect('Content-Type', /application\/json/) .expect('Content-Disposition', 'Attachment; filename="redirects.json"') - .expect(200); + .expect(200) + .expect((res) => { + res.body.should.eql([ + {from: '^/post/[0-9]+/([a-z0-9\\-]+)', to: '/$1'}, + {permanent: true, from: '/my-old-blog-post/', to: '/revamped-url/'}, + {permanent: true, from: '/test-params', to: '/result?q=abc'}, + {from: '^\\/what(\\/?)$', to: '/what-does-god-say'}, + {from: '^\\/search\\/label\\/([^\\%20]+)$', to: '/tag/$1'}, + {from: '^\\/topic\\/', to: '/'}, + {from: '^/resources\\/download(\\/?)$', to: '/shubal-stearns'}, + {from: '^/(?:capture1|capture2)/([A-Za-z0-9\\-]+)', to: '/$1'}, + { + from: '^\\/[0-9]{4}\\/[0-9]{2}\\/([a-z0-9\\-]+)(\\.html)?(\\/)?$', + to: '/$1' + }, + {from: '^/prefix/([a-z0-9\\-]+)?', to: '/blog/$1'}, + {from: '/^\\/case-insensitive/i', to: '/redirected-insensitive'}, + {from: '^\\/Case-Sensitive', to: '/redirected-sensitive'}, + {from: '^\\/Default-Sensitive', to: '/redirected-default'}, + {from: '/external-url', to: 'https://ghost.org'}, + {from: '/external-url/(.*)', to: 'https://ghost.org/$1'} + ]); + }); }); it('upload', function () { @@ -35,6 +57,9 @@ describe('Redirects API', function () { .set('Origin', config.get('url')) .attach('redirects', path.join(config.get('paths:contentPath'), 'redirects-init.json')) .expect('Content-Type', /application\/json/) - .expect(200); + .expect(200) + .expect((res) => { + res.body.should.be.empty(); + }); }); });