Skip to content

Commit 4c82bb8

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): percent encode asset URLs in development server for esbuild
When using the esbuild-based browser application builder with the development server, configured application assets are served directly from disk. The URLs passed to Vite are now percent encoded to properly handle asset paths that may contain unsupported URL characters.
1 parent a649117 commit 4c82bb8

File tree

1 file changed

+2
-2
lines changed
  • packages/angular_devkit/build_angular/src/builders/dev-server

1 file changed

+2
-2
lines changed

packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export async function setupServer(
255255
// Parse the incoming request.
256256
// The base of the URL is unused but required to parse the URL.
257257
const parsedUrl = new URL(req.url, 'http://localhost');
258-
let pathname = parsedUrl.pathname;
258+
let pathname = decodeURIComponent(parsedUrl.pathname);
259259
if (serverOptions.servePath && pathname.startsWith(serverOptions.servePath)) {
260260
pathname = pathname.slice(serverOptions.servePath.length);
261261
if (pathname[0] !== '/') {
@@ -267,7 +267,7 @@ export async function setupServer(
267267
// Rewrite all build assets to a vite raw fs URL
268268
const assetSourcePath = assets.get(pathname);
269269
if (assetSourcePath !== undefined) {
270-
req.url = `/@fs/${normalizePath(assetSourcePath)}`;
270+
req.url = `/@fs/${encodeURIComponent(assetSourcePath)}`;
271271
next();
272272

273273
return;

0 commit comments

Comments
 (0)