diff --git a/utils/createPathFormatter.ts b/utils/createPathFormatter.ts index 52c9527c6d8c6756125c2f746cf14d055ed1e3ef..b7c950190142168447bf3cc2d0c65a306965ac98 100644 --- a/utils/createPathFormatter.ts +++ b/utils/createPathFormatter.ts @@ -37,7 +37,8 @@ function formatPath( href: string, { format = 'directory', trailingSlash = 'ignore' }: FormatPathOptions ) { - const formatStrategy = formatStrategies[format]; + const useCleanFileUrls = format === 'file' && trailingSlash === 'never'; + const formatStrategy = useCleanFileUrls ? defaultFormatStrategy : formatStrategies[format]; const trailingSlashStrategy = trailingSlashStrategies[trailingSlash]; // Handle extension @@ -47,7 +48,7 @@ function formatPath( href = formatStrategy.addBase(href); // Skip trailing slash handling for `build.format: 'file'` - if (format === 'file') return href; + if (format === 'file' && !useCleanFileUrls) return href; // Handle trailing slash href = href === '/' ? href : trailingSlashStrategy(href);