Merge pull request #20710 from calixteman/normalize_path

Remove the leading slash in windows file path when instrumenting js files for ccov
This commit is contained in:
calixteman 2026-02-22 13:40:13 +01:00 committed by GitHub
commit 1df6367ef9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -306,7 +306,15 @@ class WebServer {
// Transform with Babel and istanbul plugin
const result = babel.transformSync(content, {
filename: fileURL.pathname,
// On Windows, the file URL starts with a slash (e.g.
// /C:/path/to/file.js).
// This leading slash makes the file path invalid and causes the
// instrumentation to fail, so we need to remove it before passing the
// path.
filename:
process.platform === "win32"
? fileURL.pathname.substring(1)
: fileURL.pathname,
plugins: ["babel-plugin-istanbul"],
sourceMaps: false,
});