Skip to content

Commit deb9b31

Browse files
authored
feature: report: ability to use dynamic source maps for ?count=x imported files (#325)
1 parent eaf8456 commit deb9b31

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
@@ -93,7 +93,7 @@ class Report {
9393
for (const v8ScriptCov of v8ProcessCov.result) {
9494
try {
9595
const sources = this._getSourceMap(v8ScriptCov)
96-
const path = resolve(this.resolve, v8ScriptCov.url)
96+
const path = resolve(this.resolve, fileURLToPath(v8ScriptCov.url))
9797
const converter = v8toIstanbul(path, this.wrapperLength, sources, (path) => {
9898
if (this.excludeAfterRemap) {
9999
return !this.exclude.shouldInstrument(path)
@@ -143,7 +143,7 @@ class Report {
143143
*/
144144
_getSourceMap (v8ScriptCov) {
145145
const sources = {}
146-
const sourceMapAndLineLengths = this.sourceMapCache[pathToFileURL(v8ScriptCov.url).href]
146+
const sourceMapAndLineLengths = this.sourceMapCache[v8ScriptCov.url]
147147
if (sourceMapAndLineLengths) {
148148
// See: https://github.com/nodejs/node/pull/34305
149149
if (!sourceMapAndLineLengths.data) return
@@ -279,15 +279,15 @@ class Report {
279279
}
280280
if (/^file:\/\//.test(v8ScriptCov.url)) {
281281
try {
282-
v8ScriptCov.url = fileURLToPath(v8ScriptCov.url)
283282
fileIndex.add(v8ScriptCov.url)
284283
} catch (err) {
285284
debuglog(`${err.stack}`)
286285
continue
287286
}
288287
}
289-
if ((!this.omitRelative || isAbsolute(v8ScriptCov.url))) {
290-
if (this.excludeAfterRemap || this.exclude.shouldInstrument(v8ScriptCov.url)) {
288+
289+
if ((!this.omitRelative || /^file:\/\//.test(v8ScriptCov.url))) {
290+
if (this.excludeAfterRemap || this.exclude.shouldInstrument(fileURLToPath(v8ScriptCov.url))) {
291291
result.push(v8ScriptCov)
292292
}
293293
}
@@ -307,7 +307,7 @@ class Report {
307307
_normalizeSourceMapCache (v8SourceMapCache) {
308308
const cache = {}
309309
for (const fileURL of Object.keys(v8SourceMapCache)) {
310-
cache[pathToFileURL(fileURLToPath(fileURL)).href] = v8SourceMapCache[fileURL]
310+
cache[fileURL] = v8SourceMapCache[fileURL];
311311
}
312312
return cache
313313
}

0 commit comments

Comments
 (0)