File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -359,6 +359,20 @@ export function createApp(siteId: string) {
359
359
blobKey = manifest . paths [ `${ urlPath } /index.html` ] ;
360
360
}
361
361
362
+ // If a blob wasn't found, and if the URL ends with ".html", and if a
363
+ // corresponding blob exists at a clean URL, redirect automatically.
364
+ // For example, this will redirect `/foo/bar.html` to `/foo/bar/` if
365
+ // `/foo/bar/index.html` exists in the manifest.
366
+ const cleanPath = urlPath . replace ( / \. h t m l $ / , '' ) ;
367
+ if (
368
+ ! blobKey &&
369
+ urlPath . endsWith ( '.html' ) &&
370
+ manifestPaths [ `${ cleanPath } /index.html` ]
371
+ ) {
372
+ res . redirect ( 301 , preserveQueryString ( req , `${ cleanPath } /` ) ) ;
373
+ return ;
374
+ }
375
+
362
376
if ( ! blobKey ) {
363
377
// Trailing slash redirect.
364
378
if (
You can’t perform that action at this time.
0 commit comments