fix(striker-ui-api): handle static file requests with file extension

main
Tsu-ba-me 2 years ago
parent bfadd3bacb
commit c6bcbc952b
  1. 3
      striker-ui-api/src/routes/static.ts

@ -26,8 +26,9 @@ router.use(
const parts = originalUrl.replace(/[/]$/, '').split('/'); const parts = originalUrl.replace(/[/]$/, '').split('/');
const tail = parts.pop() || 'index'; const tail = parts.pop() || 'index';
const extended = /[.]html$/.test(tail) ? tail : `${tail}.html`;
parts.push(`${tail}.html`); parts.push(extended);
const htmlPath = path.posix.join(htmlDir, ...parts); const htmlPath = path.posix.join(htmlDir, ...parts);
const isHtmlExists = existsSync(htmlPath); const isHtmlExists = existsSync(htmlPath);

Loading…
Cancel
Save