File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,12 @@ export function parsePatch(uniDiff, options = {}) {
5353 // Parses the --- and +++ headers, if none are found, no lines
5454 // are consumed.
5555 function parseFileHeader ( index ) {
56- const fileHeader = ( / ^ ( - - - | \+ \+ \+ ) \s + ( . * ) $ / ) . exec ( diffstr [ i ] ) ;
57- if ( fileHeader ) {
58- let keyPrefix = fileHeader [ 1 ] === '---' ? 'old' : 'new' ;
59- const data = fileHeader [ 2 ] . split ( '\t' , 2 ) ;
56+ const fileHeaderMatch = ( / ^ ( - - - | \+ \+ \+ ) \s + / ) . exec ( diffstr [ i ] ) ;
57+ if ( fileHeaderMatch ) {
58+ let keyPrefix = fileHeaderMatch [ 1 ] === '---' ? 'old' : 'new' ;
59+ const data = diffstr [ i ] . substring ( 3 ) . trim ( ) . split ( '\t' , 2 ) ;
6060 let fileName = data [ 0 ] . replace ( / \\ \\ / g, '\\' ) ;
61- if ( ( / ^ " . * " $ / ) . test ( fileName ) ) {
61+ if ( fileName . startsWith ( '"' ) && fileName . endsWith ( '"' ) ) {
6262 fileName = fileName . substr ( 1 , fileName . length - 2 ) ;
6363 }
6464 index [ keyPrefix + 'FileName' ] = fileName ;
You can’t perform that action at this time.
0 commit comments