Skip to content

Commit 157da19

Browse files
committed
feature: report: ability to use dynamic source maps for ?count=x imported files (#325)
1 parent dc38051 commit 157da19

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

lib/report.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Report {
109109
for (const v8ScriptCov of v8ProcessCov.result) {
110110
try {
111111
const sources = this._getSourceMap(v8ScriptCov)
112-
const path = resolve(this.resolve, v8ScriptCov.url)
112+
const path = resolve(this.resolve, fileURLToPath(v8ScriptCov.url))
113113
const converter = v8toIstanbul(path, this.wrapperLength, sources, (path) => {
114114
if (this.excludeAfterRemap) {
115115
return !this._shouldInstrument(path)
@@ -146,7 +146,7 @@ class Report {
146146
*/
147147
_getSourceMap (v8ScriptCov) {
148148
const sources = {}
149-
const sourceMapAndLineLengths = this.sourceMapCache[pathToFileURL(v8ScriptCov.url).href]
149+
const sourceMapAndLineLengths = this.sourceMapCache[v8ScriptCov.url]
150150
if (sourceMapAndLineLengths) {
151151
// See: https://github.com/nodejs/node/pull/34305
152152
if (!sourceMapAndLineLengths.data) return
@@ -346,15 +346,15 @@ class Report {
346346
}
347347
if (/^file:\/\//.test(v8ScriptCov.url)) {
348348
try {
349-
v8ScriptCov.url = fileURLToPath(v8ScriptCov.url)
350349
fileIndex.add(v8ScriptCov.url)
351350
} catch (err) {
352351
debuglog(`${err.stack}`)
353352
continue
354353
}
355354
}
356-
if ((!this.omitRelative || isAbsolute(v8ScriptCov.url))) {
357-
if (this.excludeAfterRemap || this._shouldInstrument(v8ScriptCov.url)) {
355+
356+
if ((!this.omitRelative || /^file:\/\//.test(v8ScriptCov.url))) {
357+
if (this.excludeAfterRemap || this.exclude.shouldInstrument(fileURLToPath(v8ScriptCov.url))) {
358358
result.push(v8ScriptCov)
359359
}
360360
}
@@ -374,7 +374,7 @@ class Report {
374374
_normalizeSourceMapCache (v8SourceMapCache) {
375375
const cache = {}
376376
for (const fileURL of Object.keys(v8SourceMapCache)) {
377-
cache[pathToFileURL(fileURLToPath(fileURL)).href] = v8SourceMapCache[fileURL]
377+
cache[fileURL] = v8SourceMapCache[fileURL];
378378
}
379379
return cache
380380
}

0 commit comments

Comments
 (0)