diff --git a/test/integration/public-dir/test/index.test.js b/test/integration/public-dir/test/index.test.js index ea5f5f157cc1b..89a424b1dcc4f 100644 --- a/test/integration/public-dir/test/index.test.js +++ b/test/integration/public-dir/test/index.test.js @@ -7,6 +7,7 @@ import { startApp, stopApp, renderViaHTTP, + fetchViaHTTP, } from 'next-test-utils' const appDir = join(__dirname, '../') @@ -41,13 +42,43 @@ describe('Public Files', () => { expect(html).toMatch(/i have a plus/) }) + it('should not stream the file + with trailing slash', async () => { + const res = await fetchViaHTTP(appPort, `/test+this.txt/`) + expect(res.status).toBe(404) + }) + + it('should not stream the file + encoded', async () => { + const res = await fetchViaHTTP( + appPort, + `/test${encodeURIComponent('+')}this.txt` + ) + expect(res.status).toBe(404) + }) + it('should stream the file :', async () => { const html = await renderViaHTTP(appPort, '/test:this.txt') expect(html).toMatch(/i have a :/) }) - it('should stream the file space', async () => { - const html = await renderViaHTTP(appPort, '/test this.txt') + it('should not stream the file : encoded', async () => { + const res = await fetchViaHTTP( + appPort, + `/test${encodeURIComponent(':')}this.txt` + ) + expect(res.status).toBe(404) + }) + + xit('should stream the file space', async () => { + const html = await renderViaHTTP(appPort, '/test space.txt') + expect(html).toMatch(/i have a space/) + }) + + // Why is this one different? %20 is `encodeURI`. + xit('should stream the file space encoded', async () => { + const html = await renderViaHTTP( + appPort, + `/test${encodeURIComponent(' ')}space.txt` + ) expect(html).toMatch(/i have a space/) }) })