11const Exclude = require ( 'test-exclude' )
2+ const furi = require ( 'furi' )
23const libCoverage = require ( 'istanbul-lib-coverage' )
34const libReport = require ( 'istanbul-lib-report' )
45const reports = require ( 'istanbul-reports' )
@@ -74,7 +75,7 @@ class Report {
7475 _getMergedProcessCov ( ) {
7576 const v8ProcessCovs = [ ]
7677 for ( const v8ProcessCov of this . _loadReports ( ) ) {
77- v8ProcessCovs . push ( this . _filterProcessCov ( v8ProcessCov ) )
78+ v8ProcessCovs . push ( this . _normalizeProcessCov ( v8ProcessCov ) )
7879 }
7980 return mergeProcessCovs ( v8ProcessCovs )
8081 }
@@ -101,21 +102,26 @@ class Report {
101102 }
102103
103104 /**
104- * Returns a filtered process coverage.
105+ * Normalizes a process coverage.
106+ *
107+ * This function replaces file URLs (`url` property) by their corresponding
108+ * system-dependent path and applies the current inclusion rules to filter out
109+ * the excluded script coverages.
105110 *
106111 * The result is a copy of the input, with script coverages filtered based
107112 * on their `url` and the current inclusion rules.
108113 * There is no deep cloning.
109114 *
110- * @param v8ProcessCov V8 process coverage to filter .
111- * @return {v8ProcessCov } Filtered V8 process coverage.
115+ * @param v8ProcessCov V8 process coverage to normalize .
116+ * @return {v8ProcessCov } Normalized V8 process coverage.
112117 * @private
113118 */
114- _filterProcessCov ( v8ProcessCov ) {
119+ _normalizeProcessCov ( v8ProcessCov ) {
115120 const result = [ ]
116121 for ( const v8ScriptCov of v8ProcessCov . result ) {
117- // TODO: implement real fix from https://github.com/nodejs/node/issues/23783
118- v8ScriptCov . url = v8ScriptCov . url . replace ( / ^ f i l e : \/ \/ / , '' )
122+ if ( / ^ f i l e : \/ \/ / . test ( v8ScriptCov . url ) ) {
123+ v8ScriptCov . url = furi . toSysPath ( v8ScriptCov . url )
124+ }
119125 if ( this . exclude . shouldInstrument ( v8ScriptCov . url ) &&
120126 ( ! this . omitRelative || isAbsolute ( v8ScriptCov . url ) ) ) {
121127 result . push ( v8ScriptCov )
0 commit comments