diff options
author | 2022-11-11 11:34:34 -0800 | |
---|---|---|
committer | 2022-11-11 11:34:34 -0800 | |
commit | bee8c14afd475ad053b9fdf78a2d29bebdd86926 (patch) | |
tree | 0c6bcc50b58a8ec378298d8e32d890a59090b439 /packages/astro/test/ssr-request.test.js | |
parent | f47fb995c0dd5943deffbab082abbfb3977d062b (diff) | |
download | astro-bee8c14afd475ad053b9fdf78a2d29bebdd86926.tar.gz astro-bee8c14afd475ad053b9fdf78a2d29bebdd86926.tar.zst astro-bee8c14afd475ad053b9fdf78a2d29bebdd86926.zip |
Use base rather than site to create subpath for links/scripts (#5371)
* Use base rather than site to create subpath for links/scripts
* Adding a changeset
* Warn when the site has a pathname but not using base
* fix asset test
* fix asset inlining behavior
Diffstat (limited to '')
-rw-r--r-- | packages/astro/test/ssr-request.test.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/astro/test/ssr-request.test.js b/packages/astro/test/ssr-request.test.js index 8f5c242a4..42817abc5 100644 --- a/packages/astro/test/ssr-request.test.js +++ b/packages/astro/test/ssr-request.test.js @@ -13,6 +13,11 @@ describe('Using Astro.request in SSR', () => { adapter: testAdapter(), output: 'server', base: '/subpath/', + vite: { + build: { + assetsInlineLimit: 0 + } + } }); await fixture.build(); }); @@ -51,6 +56,25 @@ describe('Using Astro.request in SSR', () => { expect(css).to.not.be.an('undefined'); }); + it('script assets have their base prefix', async () => { + const app = await fixture.loadTestAdapterApp(); + let request = new Request('http://example.com/subpath/request'); + let response = await app.render(request); + expect(response.status).to.equal(200); + const html = await response.text(); + const $ = cheerioLoad(html); + + const scriptSrc = $('script').attr('src'); + expect(scriptSrc.startsWith('/subpath/')).to.equal(true); + + request = new Request('http://example.com' + scriptSrc); + response = await app.render(request); + + expect(response.status).to.equal(200); + const js = await response.text(); + expect(js).to.not.be.an('undefined'); + }); + it('assets can be fetched', async () => { const app = await fixture.loadTestAdapterApp(); const request = new Request('http://example.com/subpath/cars.json'); |