@@ -66,21 +66,27 @@ export async function v8ToIstanbul(
66
66
const istanbulCoverage : CoverageMapData = { } ;
67
67
68
68
for ( const entry of coverage ) {
69
- const url = new URL ( entry . url ) ;
70
- const path = url . pathname ;
71
- if (
72
- // ignore non-http protocols (for exmaple webpack://)
73
- url . protocol . startsWith ( 'http' ) &&
74
- // ignore external urls
75
- url . hostname === config . hostname &&
76
- url . port === `${ config . port } ` &&
77
- // ignore non-files
78
- ! ! extname ( path ) &&
79
- // ignore virtual files
80
- ! path . startsWith ( '/__web-test-runner' ) &&
81
- ! path . startsWith ( '/__web-dev-server' )
82
- ) {
83
- try {
69
+ let url ;
70
+ try {
71
+ url = new URL ( entry . url ) ;
72
+ } catch ( _ ) {
73
+ // ignore invalid URLs
74
+ continue ;
75
+ }
76
+ try {
77
+ const path = url . pathname ;
78
+ if (
79
+ // ignore non-http protocols (for example webpack://)
80
+ url . protocol . startsWith ( 'http' ) &&
81
+ // ignore external urls
82
+ url . hostname === config . hostname &&
83
+ url . port === `${ config . port } ` &&
84
+ // ignore non-files
85
+ ! ! extname ( path ) &&
86
+ // ignore virtual files
87
+ ! path . startsWith ( '/__web-test-runner' ) &&
88
+ ! path . startsWith ( '/__web-dev-server' )
89
+ ) {
84
90
const filePath = join ( config . rootDir , toFilePath ( path ) ) ;
85
91
86
92
if ( ! testFiles . includes ( filePath ) && included ( filePath ) && ! excluded ( filePath ) ) {
@@ -110,10 +116,10 @@ export async function v8ToIstanbul(
110
116
converter . applyCoverage ( entry . functions ) ;
111
117
Object . assign ( istanbulCoverage , converter . toIstanbul ( ) ) ;
112
118
}
113
- } catch ( error ) {
114
- console . error ( `Error while generating code coverage for ${ entry . url } .` ) ;
115
- console . error ( error ) ;
116
119
}
120
+ } catch ( error ) {
121
+ console . error ( `Error while generating code coverage for ${ entry . url } .` ) ;
122
+ console . error ( error ) ;
117
123
}
118
124
}
119
125
0 commit comments