Skip to content

Commit c8643ed

Browse files
refactor(@angular/build): use path.posix.basename for dotfile check
Apply Gemini Code Assist suggestion: use basename from node:path/posix instead of manual string manipulation. This is more readable and correctly handles trailing slashes (e.g., /.env/ -> .env). Made-with: Cursor
1 parent 8c1a129 commit c8643ed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/angular/build/src/tools/vite/middlewares/html-fallback-middleware.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import type { ServerResponse } from 'node:http';
10+
import { basename } from 'node:path/posix';
1011
import type { Connect } from 'vite';
1112
import { lookupMimeTypeFromRequest } from '../utils';
1213

@@ -29,7 +30,7 @@ export function angularHtmlFallbackMiddleware(
2930
if (req.url) {
3031
// No fallback for dotfile requests (e.g., .env, .npmrc)
3132
const pathname = req.url.split('?')[0];
32-
const lastSegment = pathname.substring(pathname.lastIndexOf('/') + 1);
33+
const lastSegment = basename(pathname);
3334
if (lastSegment.startsWith('.')) {
3435
next();
3536

0 commit comments

Comments
 (0)