Skip to content

fix(@angular/build): normalize karma asset paths before lookup #29923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { findTests, getTestEntrypoints } from './find-tests';
import { Schema as KarmaBuilderOptions } from './schema';

const localResolve = createRequire(__filename).resolve;
const isWindows = process.platform === 'win32';

interface BuildOptions extends ApplicationBuilderInternalOptions {
// We know that it's always a string since we set it.
Expand Down Expand Up @@ -69,7 +70,14 @@ class AngularAssetsMiddleware {
let err = null;
try {
const url = new URL(`http://${req.headers['host']}${req.url}`);
const file = this.latestBuildFiles.files[url.pathname.slice(1)];
// Remove the leading slash from the URL path and convert to platform specific.
// The latest build files will use the platform path separator.
let pathname = url.pathname.slice(1);
if (isWindows) {
pathname = pathname.replaceAll(path.posix.sep, path.win32.sep);
}

const file = this.latestBuildFiles.files[pathname];

if (file?.origin === 'disk') {
this.serveFile(file.inputPath, undefined, res);
Expand Down