File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -53,16 +53,25 @@ class Keychain {
5353    try  { 
5454      const  csvData  =  papaparse . parse ( fileContents ,  { 
5555        header : true , 
56-         skipEmptyLines :true , 
57-         transformHeader ( header )  { 
56+         skipEmptyLines :  true , 
57+         transformHeader   ( header )  { 
5858          return  header . toLowerCase ( ) . trim ( ) . replace ( / [ " ' ] / g,  '' ) 
59-         } , 
59+         } 
6060      } ) 
61-       const  credentialsToImport  =  csvData . data . map ( ( credential )  =>  ( { 
62-         domain : credential . url , 
63-         username : credential . username , 
64-         password : credential . password 
65-       } ) ) 
61+       const  credentialsToImport  =  csvData . data . map ( ( credential )  =>  { 
62+         try  { 
63+           const  includesProtocol  =  credential . url . match ( / ^ h t t p s ? : \/ \/ / g) 
64+           const  domainWithProtocol  =  includesProtocol  ? credential . url  : `https://${ credential . url }  ` 
65+ 
66+           return  { 
67+             domain : new  URL ( domainWithProtocol ) . hostname . replace ( / ^ w w w \. / g,  '' ) , 
68+             username : credential . username , 
69+             password : credential . password 
70+           } 
71+         }  catch  { 
72+           return  null 
73+         } 
74+       } ) . filter ( credential  =>  credential  !==  null ) 
6675
6776      if  ( credentialsToImport . length  ===  0 )  return  [ ] 
6877
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ const passwordViewer = {
129129        throw  new  Error ( 'unsupported password manager' ) 
130130      } 
131131
132-       const  credentials  =  await  manager . getAllCredentials ( ) ; 
132+       const  credentials  =  await  manager . getAllCredentials ( ) 
133133      const  shouldShowConsent  =  credentials . length  >  0 
134134
135135      if  ( shouldShowConsent )  { 
@@ -179,7 +179,7 @@ const passwordViewer = {
179179        if  ( credentials . length  ===  0 )  return 
180180
181181        const  header  =  'url,username,password\n' 
182-         const  csvData  =  header  +  credentials . map ( credential  =>  `${ credential . domain }  ,${ credential . username }  ,${ credential . password }  ` ) . join ( '\n' ) 
182+         const  csvData  =  header  +  credentials . map ( credential  =>  `https:// ${ credential . domain }  ,${ credential . username }  ,${ credential . password }  ` ) . join ( '\n' ) 
183183        const  blob  =  new  Blob ( [ csvData ] ,  {  type : 'text/csv'  } ) 
184184        const  url  =  URL . createObjectURL ( blob ) 
185185        const  anchor  =  document . createElement ( 'a' ) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments