Skip to content

Commit 4568cae

Browse files
Backport #649
1 parent 4de0ffa commit 4568cae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/patch/parse.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)