diff options
author | 2024-01-25 11:23:27 +0100 | |
---|---|---|
committer | 2024-01-25 10:23:27 +0000 | |
commit | f7f19bfa5b6b8d41a7ba3884d455961e817ec676 (patch) | |
tree | c3c13fbb65cb4a290857780af582f558293ccadd /packages/integrations/node/test/prerender.test.js | |
parent | 1901ed3ef5e798dd3b69e1b6c05db94b6a471ad2 (diff) | |
download | astro-f7f19bfa5b6b8d41a7ba3884d455961e817ec676.tar.gz astro-f7f19bfa5b6b8d41a7ba3884d455961e817ec676.tar.zst astro-f7f19bfa5b6b8d41a7ba3884d455961e817ec676.zip |
feat(node): add trailingSlash support (#9080)
* feat(node): add trailing slash support
* add changeset
* test(node): add base route test in trailing-slash.js
detected an infinite loop in base path when trailingSlash: never
* fix(node): avoid infinite redirect when trailingSlash: never
* address test failures after rebase pt.1
* address test failures after rebase pt.2
---------
Co-authored-by: lilnasy <69170106+lilnasy@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/node/test/prerender.test.js')
-rw-r--r-- | packages/integrations/node/test/prerender.test.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/packages/integrations/node/test/prerender.test.js b/packages/integrations/node/test/prerender.test.js index 84f599bcd..86a7d3a65 100644 --- a/packages/integrations/node/test/prerender.test.js +++ b/packages/integrations/node/test/prerender.test.js @@ -74,12 +74,14 @@ describe('Prerendering', () => { expect($('h1').text()).to.equal('Two'); }); - it('Omitting the trailing slash results in a redirect that includes the base', async () => { + it('Can render prerendered route without trailing slash', async () => { const res = await fetch(`http://${server.host}:${server.port}/some-base/two`, { redirect: 'manual', }); - expect(res.status).to.equal(301); - expect(res.headers.get('location')).to.equal('/some-base/two/'); + const html = await res.text(); + const $ = cheerio.load(html); + expect(res.status).to.equal(200); + expect($('h1').text()).to.equal('Two'); }); }); @@ -241,12 +243,14 @@ describe('Hybrid rendering', () => { expect($('h1').text()).to.equal('One'); }); - it('Omitting the trailing slash results in a redirect that includes the base', async () => { + it('Can render prerendered route without trailing slash', async () => { const res = await fetch(`http://${server.host}:${server.port}/some-base/one`, { redirect: 'manual', }); - expect(res.status).to.equal(301); - expect(res.headers.get('location')).to.equal('/some-base/one/'); + const html = await res.text(); + const $ = cheerio.load(html); + expect(res.status).to.equal(200); + expect($('h1').text()).to.equal('One'); }); }); |