Repository: withastro/astro
File: packages/astro/src/core/config/schemas/refined.ts (TypeScript)

Code before:
			});
		}

		if (
			pathname &&
			pathname.includes('*') &&
			!(pathname.endsWith('/*') || pathname.endsWith('/**'))
		) {
			ctx.addIssue({
				code: z.ZodIssueCode.custom,
				message: 'wildcards can only be placed at the end of a pathname',
				path: ['image', 'remotePatterns', i, 'pathname'],
			});
		}
	}

	if (
		config.i18n &&
		typeof config.i18n.routing !== 'string' &&
		config.i18n.routing.prefixDefaultLocale === false &&
		config.i18n.routing.redirectToDefaultLocale === true
	) {
		ctx.addIssue({
			code: z.ZodIssueCode.custom,
			message:
				'The option `i18n.routing.redirectToDefaultLocale` can be used only when `i18n.routing.prefixDefaultLocale` is set to `true`; setting `i18n.routing.prefixDefaultLocale` to `false` might cause infinite loops. Remove the option `i18n.routing.prefixDefaultLocale`, or change its value to `true`.',
			path: ['i18n', 'routing', 'redirectToDefaultLocale'],
		});
	}

	if (config.outDir.toString().startsWith(config.publicDir.toString())) {
		ctx.addIssue({
			code: z.ZodIssueCode.custom,
			message:
				'The value of `outDir` must not point to a path within the folder set as `publicDir`, this will cause an infinite loop',
			path: ['outDir'],
		});
	}

	if (config.i18n) {
		const { defaultLocale, locales: _locales, fallback, domains } = config.i18n;
		const locales = _locales.map((locale) => {
			if (typeof locale === 'string') {
				return locale;
			} else {
				return locale.path;
			}
		});
		if (!locales.includes(defaultLocale)) {
			ctx.addIssue({
				code: z.ZodIssueCode.custom,

Review comment (bug):
Is the better advice not to remove the `redirectToDefaultLocale: true` rather than changing the prefix option? I’d imagine usually you don’t want to switch whether you’re prefixing or not but would not mind disabling the redirect?

```suggestion
				'The option `i18n.routing.redirectToDefaultLocale` can be used only when `i18n.routing.prefixDefaultLocale` is set to `true`, otherwise redirects might cause infinite loops. Remove the option `i18n.routing.redirectToDefaultLocale`, or change its value to `false`.',
```

Code after:
			});
		}

		if (
			pathname &&
			pathname.includes('*') &&
			!(pathname.endsWith('/*') || pathname.endsWith('/**'))
		) {
			ctx.addIssue({
				code: z.ZodIssueCode.custom,
				message: 'wildcards can only be placed at the end of a pathname',
				path: ['image', 'remotePatterns', i, 'pathname'],
			});
		}
	}

	// TODO: Astro 6.0
	// Uncomment this validation check, and change the default value of redirectToDefaultLocale to false
	// if (
	// 	config.i18n &&
	// 	typeof config.i18n.routing !== 'string' &&
	// 	config.i18n.routing.prefixDefaultLocale === false &&
	// 	config.i18n.routing.redirectToDefaultLocale === true
	// ) {
	// 	ctx.addIssue({
	// 		code: z.ZodIssueCode.custom,
	// 		message:
	// 			'The option `i18n.routing.redirectToDefaultLocale` can be used only when `i18n.routing.prefixDefaultLocale` is set to `true`, otherwise redirects might cause infinite loops. Remove the option `i18n.routing.redirectToDefaultLocale`, or change its value to `false`.',
	// 		path: ['i18n', 'routing', 'redirectToDefaultLocale'],
	// 	});
	// }

	if (config.outDir.toString().startsWith(config.publicDir.toString())) {
		ctx.addIssue({
			code: z.ZodIssueCode.custom,
			message:
				'The value of `outDir` must not point to a path within the folder set as `publicDir`, this will cause an infinite loop',
			path: ['outDir'],
		});
	}

	if (config.i18n) {
		const { defaultLocale, locales: _locales, fallback, domains } = config.i18n;
		const locales = _locales.map((locale) => {
			if (typeof locale === 'string') {
				return locale;
			} else {
				return locale.path;
			}
		});
		if (!locales.includes(defaultLocale)) {