Repository: withastro/astro
File: packages/astro/test/i18n-routing.test.js (JavaScript)

Code before:
			let request = new Request('http://example.com/new-site/it/start');
			let response = await app.render(request);
			assert.equal(response.status, 302);
			assert.equal(response.headers.get('location'), '/new-site/start');
		});

		it('should redirect to the english locale when locale has codes+path', async () => {
			let request = new Request('http://example.com/new-site/spanish/start');
			let response = await app.render(request);
			assert.equal(response.status, 302);
			assert.equal(response.headers.get('location'), '/new-site/start');
		});

		it("should render a 404 because the route `fr` isn't included in the list of locales of the configuration", async () => {
			let request = new Request('http://example.com/new-site/fr/start');
			let response = await app.render(request);
			assert.equal(response.status, 404);
		});

		it('should pass search to render when using requested locale', async () => {
			let request = new Request('http://example.com/new-site/pt/start?search=1');
			let response = await app.render(request);
			assert.equal(response.status, 200);
			const text = await response.text();
			assert.equal(text.includes('Oi essa e start'), true);
			assert.equal(text.includes('search=1'), true);
		});

		it('should include search on the redirect when using fallback', async () => {
			let request = new Request('http://example.com/new-site/it/start?search=1');
			let response = await app.render(request);
			assert.equal(response.status, 302);
			assert.equal(response.headers.get('location'), '/new-site/start?search=1');
		});

		describe('with routing strategy [pathname-prefix-always]', () => {
			before(async () => {
				fixture = await loadFixture({
					root: './fixtures/i18n-routing-fallback/',
					output: 'server',
					adapter: testAdapter(),
					i18n: {
						defaultLocale: 'en',
						locales: ['en', 'pt', 'it'],
						fallback: {
							it: 'en',
						},
						routing: {
							prefixDefaultLocale: false,
						},
					},

Review comment (suggestion):
```suggestion
			assert.match(text, /Oi essa e start/);
			assert.match(text, /search=1/);
```

Code after:
			let request = new Request('http://example.com/new-site/it/start');
			let response = await app.render(request);
			assert.equal(response.status, 302);
			assert.equal(response.headers.get('location'), '/new-site/start');
		});

		it('should redirect to the english locale when locale has codes+path', async () => {
			let request = new Request('http://example.com/new-site/spanish/start');
			let response = await app.render(request);
			assert.equal(response.status, 302);
			assert.equal(response.headers.get('location'), '/new-site/start');
		});

		it("should render a 404 because the route `fr` isn't included in the list of locales of the configuration", async () => {
			let request = new Request('http://example.com/new-site/fr/start');
			let response = await app.render(request);
			assert.equal(response.status, 404);
		});

		it('should pass search to render when using requested locale', async () => {
			let request = new Request('http://example.com/new-site/pt/start?search=1');
			let response = await app.render(request);
			assert.equal(response.status, 200);
			const text = await response.text();
			assert.match(text, /Oi essa e start/);
			assert.match(text, /search=1/);
		});

		it('should include search on the redirect when using fallback', async () => {
			let request = new Request('http://example.com/new-site/it/start?search=1');
			let response = await app.render(request);
			assert.equal(response.status, 302);
			assert.equal(response.headers.get('location'), '/new-site/start?search=1');
		});

		describe('with routing strategy [pathname-prefix-always]', () => {
			before(async () => {
				fixture = await loadFixture({
					root: './fixtures/i18n-routing-fallback/',
					output: 'server',
					adapter: testAdapter(),
					i18n: {
						defaultLocale: 'en',
						locales: ['en', 'pt', 'it'],
						fallback: {
							it: 'en',
						},
						routing: {
							prefixDefaultLocale: false,
						},
					},