@@ -121,11 +121,10 @@ export default class Utils {
121121 getScanPaths ( ) : string [ ] {
122122 const list : ComponentDataType [ ] = this . getScanList ( ) ;
123123 const pathList : string [ ] = [ ] ;
124-
124+ const splitSep = path . sep ;
125125 list . forEach ( item => {
126126 const path = item . paths [ 0 ] ;
127- // const itemPath = path.slice(0, path.indexOf('/[')).replace(this.workspacePath.replace(/\\/g, '/'), '');
128- const itemPath = path . slice ( 0 , path . indexOf ( '\\[' ) ) ;
127+ const itemPath = path . slice ( 0 , path . indexOf ( splitSep + '[' ) ) ;
129128 if ( pathList . indexOf ( itemPath ) === - 1 ) {
130129 pathList . push ( itemPath ) ;
131130 }
@@ -200,11 +199,12 @@ export default class Utils {
200199 } ;
201200
202201 const newList = _uniqWith ( list ) ;
202+ const splitSep = path . sep ;
203203 return newList . map ( item => {
204204 const completePath = item . paths [ 0 ] ;
205- const completeLocation = completePath . slice ( 0 , completePath . indexOf ( '\\ [') ) ;
206- const location = completeLocation . replace ( this . workspacePath . replace ( / \\ / g , '/' ) , '' ) ;
207- const componentPath = completePath . slice ( completePath . indexOf ( '\\ [') + 1 ) . replace ( / \\ \[ / g , '->[ ' ) ;
205+ const completeLocation = completePath . slice ( 0 , completePath . indexOf ( splitSep + ' [') ) ;
206+ const location = completeLocation . replace ( this . workspacePath . replace ( new RegExp ( splitSep , 'g' ) , '/' ) , '' ) ;
207+ const componentPath = completePath . slice ( completePath . indexOf ( splitSep + ' [') + 1 ) . replace ( new RegExp ( splitSep , 'g' ) , '->' ) ;
208208 const vulList = ( item . vulnerabilities || [ ] ) . sort ( ( a : VulDataType , b : VulDataType ) => a . security_level_id - b . security_level_id ) ;
209209 if ( vulList . length ) {
210210 item . security_level_id = vulList [ 0 ] . security_level_id ;
@@ -219,7 +219,7 @@ export default class Utils {
219219 ...item ,
220220 licenseStr : ( item . licenses || [ ] ) . map ( ( itemLicense : ItemLicense ) => itemLicense . name ) . join ( ',' ) ,
221221 vulnerabilities : ( item . vulnerabilities || [ ] ) . map ( item => ( { ...item , cve_id : item . cve_id || '' , cnnvd_id : item . cnnvd_id || '' } ) ) ,
222- completeLocation : this . workspacePath + ' ' + completeLocation . slice ( completePath . indexOf ( '\\' ) ) ,
222+ completeLocation : path . join ( this . workspacePath , '../ ' + completeLocation ) ,
223223 completePath,
224224 componentPath,
225225 location,
0 commit comments