@@ -43,7 +43,7 @@ const UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
4343 */
4444
4545// TODO refactor me in the next major release, this function should return `{ filename, stats, error }`
46- // TODO fix redirect logic when `/` at the end, like https://github.com/pillarjs/send/blob/master /index.js#L586
46+ // TODO fix redirect logic when `/` at the end, like https://github.com/pillarjs/send/blob/121dda811bae6420ce08171b10685d19c4e53059 /index.js#L426
4747/**
4848 * @template {IncomingMessage} Request
4949 * @template {ServerResponse} Response
@@ -64,6 +64,13 @@ function getFilenameFromUrl(context, url, extra = {}) {
6464 try {
6565 // The `url` property of the `request` is contains only `pathname`, `search` and `hash`
6666 urlObject = memoizedParse ( url , false , true ) ;
67+
68+ if (
69+ urlObject ?. pathname &&
70+ urlObject . pathname [ urlObject . pathname . length - 1 ] === "/"
71+ ) {
72+ urlObject . pathname = path . join ( urlObject . pathname , "index.html" ) ;
73+ }
6774 } catch {
6875 return ;
6976 }
@@ -110,10 +117,7 @@ function getFilenameFromUrl(context, url, extra = {}) {
110117 // `/complex/foo.js` => `foo.js`
111118 // and add outputPath
112119 // `foo.js` => `/home/user/my-project/dist/foo.js`
113- filename = path . join (
114- outputPath ,
115- pathname . slice ( publicPathPathname . length ) ,
116- ) ;
120+ filename = path . join ( outputPath , pathname ) ;
117121
118122 try {
119123 extra . stats = context . outputFileSystem . statSync ( filename ) ;
0 commit comments