Skip to content

Commit d868270

Browse files
committedJul 18, 2024·
fix(@angular/build): prevent redirection loop
Added handling to ensure trailing slashes on static files do not disregard query strings. Closes #28071 (cherry picked from commit 6d69375)
1 parent 2601941 commit d868270

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎packages/angular/build/src/tools/vite/middlewares/assets-middleware.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export function createAngularAssetsMiddleware(
8787
if (!pathnameHasTrailingSlash) {
8888
for (const assetPath of assets.keys()) {
8989
if (pathname === assetPath.substring(0, assetPath.lastIndexOf('/'))) {
90-
const location = req.url + '/';
90+
const { pathname, search, hash } = new URL(req.url, 'http://localhost');
91+
const location = [pathname, '/', search, hash].join('');
9192

9293
res.statusCode = 301;
9394
res.setHeader('Content-Type', 'text/html');

0 commit comments

Comments
 (0)
Please sign in to comment.