@@ -272,8 +272,9 @@ function fmtPct(pct: number): string {
272272 return ( Math . floor ( pct * 100 ) / 100 ) . toFixed ( 2 ) ;
273273}
274274
275- function shortenFilename ( filename : string , root : string ) : string {
276- return filename . replace ( root , '.' ) . replace ( / ^ \. \/ / , '' ) ;
275+ function shortenFilename ( filename : string ) : string {
276+ // Paths in the JSON output are already root-relative with a leading `/`.
277+ return filename . replace ( / ^ \/ / , '' ) ;
277278}
278279
279280function fileId ( filename : string ) : string {
@@ -413,9 +414,9 @@ function buildMissedMethodLines(methods: MethodEntry[] | undefined): Set<number>
413414 return set ;
414415}
415416
416- function renderSourceFile ( filename : string , data : FileCoverage , root : string , branchCoverage : boolean , methodCoverage : boolean ) : string {
417+ function renderSourceFile ( filename : string , data : FileCoverage , branchCoverage : boolean , methodCoverage : boolean ) : string {
417418 const id = fileId ( filename ) ;
418- const shortName = shortenFilename ( filename , root ) ;
419+ const shortName = shortenFilename ( filename ) ;
419420 const coveredLines = data . covered_lines ;
420421 const missedLines = data . missed_lines ;
421422 const totalLines = coveredLines + missedLines ;
@@ -481,7 +482,6 @@ function renderFileList(
481482 title : string ,
482483 filenames : string [ ] ,
483484 allCoverage : Record < string , FileCoverage > ,
484- root : string ,
485485 branchCoverage : boolean ,
486486 methodCoverage : boolean
487487) : string {
@@ -534,7 +534,7 @@ function renderFileList(
534534 for ( const fn of filenames ) {
535535 const f = allCoverage [ fn ] ;
536536 if ( ! f ) continue ;
537- const shortName = shortenFilename ( fn , root ) ;
537+ const shortName = shortenFilename ( fn ) ;
538538 const id = fileId ( fn ) ;
539539 const coveredLines = f . covered_lines ;
540540 const relevantLines = coveredLines + f . missed_lines ;
@@ -569,7 +569,6 @@ function renderPage(data: CoverageData): void {
569569 const meta = data . meta ;
570570 const branchCoverage = meta . branch_coverage ;
571571 const methodCoverage = meta . method_coverage ;
572- const root = meta . root ;
573572
574573 // Page title and favicon
575574 document . title = `Code coverage for ${ meta . project_name } ` ;
@@ -585,11 +584,11 @@ function renderPage(data: CoverageData): void {
585584
586585 // Content: file lists
587586 const content = document . getElementById ( 'content' ) ! ;
588- content . innerHTML = renderFileList ( 'All Files' , allFiles , data . coverage , root , branchCoverage , methodCoverage ) ;
587+ content . innerHTML = renderFileList ( 'All Files' , allFiles , data . coverage , branchCoverage , methodCoverage ) ;
589588
590589 for ( const groupName of Object . keys ( data . groups ) ) {
591590 const groupFiles = data . groups [ groupName ] . files || [ ] ;
592- content . innerHTML += renderFileList ( groupName , groupFiles , data . coverage , root , branchCoverage , methodCoverage ) ;
591+ content . innerHTML += renderFileList ( groupName , groupFiles , data . coverage , branchCoverage , methodCoverage ) ;
593592 }
594593
595594 // Build id → filename lookup map for O(1) source file materialization
@@ -599,7 +598,6 @@ function renderPage(data: CoverageData): void {
599598 }
600599 ( window as any ) . _simplecovIdMap = idToFilename ;
601600 ( window as any ) . _simplecovFiles = data . coverage ;
602- ( window as any ) . _simplecovRoot = root ;
603601 ( window as any ) . _simplecovBranchCoverage = branchCoverage ;
604602 ( window as any ) . _simplecovMethodCoverage = methodCoverage ;
605603
@@ -849,14 +847,13 @@ function materializeSourceFile(sourceFileId: string): HTMLElement | null {
849847
850848 const idMap = ( window as any ) . _simplecovIdMap as Record < string , string > ;
851849 const coverage = ( window as any ) . _simplecovFiles as Record < string , FileCoverage > ;
852- const root = ( window as any ) . _simplecovRoot as string ;
853850 const branchCov = ( window as any ) . _simplecovBranchCoverage as boolean ;
854851 const methodCov = ( window as any ) . _simplecovMethodCoverage as boolean ;
855852
856853 const targetFilename = idMap [ sourceFileId ] ;
857854 if ( ! targetFilename ) return null ;
858855
859- const html = renderSourceFile ( targetFilename , coverage [ targetFilename ] , root , branchCov , methodCov ) ;
856+ const html = renderSourceFile ( targetFilename , coverage [ targetFilename ] , branchCov , methodCov ) ;
860857 const container = document . querySelector ( '.source_files' ) ! ;
861858 const wrapper = document . createElement ( 'div' ) ;
862859 wrapper . innerHTML = html ;
0 commit comments