Skip to content

Commit

Permalink
fix: workaround for networked filesystems on Windows (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurupras committed Jul 5, 2023
1 parent 5ef82e2 commit 4de72ea
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.js
Expand Up @@ -30,6 +30,21 @@ class CoverageInstrumenter {

await this.postSession('Profiler.disable');

// When using networked filesystems on Windows, v8 sometimes returns URLs
// of the form file:////<host>/path. These URLs are not well understood
// by NodeJS (see https://github.com/nodejs/node/issues/48530).
// We circumvent this issue here by fixing these URLs.
// FWIW, Python has special code to deal with URLs like this
// https://github.com/python/cpython/blob/bef1c8761e3b0dfc5708747bb646ad8b669cbd67/Lib/nturl2path.py#L22C1-L22C1
if (process.platform === 'win32') {
const prefix = 'file:////';
result.forEach(res => {
if (res.url.startsWith(prefix)) {
res.url = 'file://' + res.url.slice(prefix.length);
}
})
}

return result;
}
}
Expand Down

0 comments on commit 4de72ea

Please sign in to comment.