File tree Expand file tree Collapse file tree 1 file changed +26
-12
lines changed 
argos@pew.worldwidemann.com Expand file tree Collapse file tree 1 file changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -69,22 +69,36 @@ export function parseFilename(filename) {
6969  return  settings ; 
7070} 
7171
72+ function  locatePipe ( str )  { 
73+   let  isEscaped  =  false ; 
74+ 
75+   for  ( let  i  =  0 ;  i  <  str . length ;  i ++ )  { 
76+     if  ( isEscaped )  { 
77+       // Previous character was a backslash, reset state after current escaped character 
78+       isEscaped  =  false ; 
79+       continue ; 
80+     } 
81+ 
82+     if  ( str [ i ]  ===  "\\" )  { 
83+       // Enter escape state 
84+       isEscaped  =  true ; 
85+       continue ; 
86+     } 
87+ 
88+     if  ( str [ i ]  ===  "|"  &&  ! isEscaped )  { 
89+       return  i ; 
90+     } 
91+   } 
92+ 
93+   return  - 1 ; 
94+ } 
95+ 
7296// Performs (mostly) BitBar-compatible output line parsing 
7397// (see https://github.com/matryer/bitbar#plugin-api) 
7498export  function  parseLine ( lineString )  { 
7599  let  line  =  { } ; 
76-   let  separatorIndex  =  undefined ; 
77- 
78-   do 
79-   { 
80-     separatorIndex  =  lineString . indexOf ( "|" ,  separatorIndex ) ; 
81-     if  ( separatorIndex  ===  0  ||  lineString [ separatorIndex - 1 ]  !=  '\\' )  { 
82-       // found a non-escaped pipe symbol 
83-       break ; 
84-     } 
85-     // keep looking 
86-     ++ separatorIndex ; 
87-   }  while ( separatorIndex  <  lineString . length ) ; 
100+ 
101+   let  separatorIndex  =  locatePipe ( lineString ) ; 
88102
89103  if  ( separatorIndex  >=  0 )  { 
90104    let  attributes  =  [ ] ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments