From c76f191b433868371d7f7ee289d821b5c95946f0 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 17 May 2023 22:58:37 -0400 Subject: [PATCH] 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. --- .../build_angular/src/builders/dev-server/vite-server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts b/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts index 8980e51586f8..412d692ce82f 100644 --- a/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts +++ b/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts @@ -255,7 +255,7 @@ export async function setupServer( // Parse the incoming request. // The base of the URL is unused but required to parse the URL. const parsedUrl = new URL(req.url, 'http://localhost'); - let pathname = parsedUrl.pathname; + let pathname = decodeURIComponent(parsedUrl.pathname); if (serverOptions.servePath && pathname.startsWith(serverOptions.servePath)) { pathname = pathname.slice(serverOptions.servePath.length); if (pathname[0] !== '/') { @@ -267,7 +267,7 @@ export async function setupServer( // Rewrite all build assets to a vite raw fs URL const assetSourcePath = assets.get(pathname); if (assetSourcePath !== undefined) { - req.url = `/@fs/${normalizePath(assetSourcePath)}`; + req.url = `/@fs/${encodeURIComponent(assetSourcePath)}`; next(); return;