Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): percent encode asset URLs in deve…
Browse files Browse the repository at this point in the history
…lopment 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.
  • Loading branch information
clydin authored and alan-agius4 committed May 19, 2023
1 parent a649117 commit 4c82bb8
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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] !== '/') {
Expand All @@ -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;
Expand Down

0 comments on commit 4c82bb8

Please sign in to comment.