| 180 | const oldMode = header.match(OLD_MODE_RE)?.[1] ?? sharedMode; |
| 181 | const newMode = header.match(NEW_MODE_RE)?.[1] ?? sharedMode; |
| 182 | const oldIsSymlink = oldMode === SYMLINK_MODE; |
| 183 | const newIsSymlink = newMode === SYMLINK_MODE; |
| 184 | const modeUnknown = |
| 185 | oldMode === undefined && newMode === undefined && RENAME_FROM_RE.test(header); |
| 186 | |
| 187 | let oldPath = decodeGitHeaderPath(text.match(MINUS_RE)?.[1], "a/"); |
| 188 | let newPath = decodeGitHeaderPath(text.match(PLUS_RE)?.[1], "b/"); |
| 189 | |
| 190 | // Pure renames/copies have no ---/+++ headers; fall back to the |
| 191 | // rename/copy header lines so their contents can still be served. |
| 192 | if (oldPath === null && newPath === null) { |
| 193 | oldPath = decodeGitHeaderPath(text.match(RENAME_FROM_RE)?.[1], null); |
| 194 | newPath = decodeGitHeaderPath(text.match(RENAME_TO_RE)?.[1], null); |
| 195 | } |
| 196 | |
| 197 | // Modified binaries emit only `diff --git` + `Binary files ... differ` |
| 198 | // (no ---/+++, no rename lines); parse the header itself so images can |
| 199 | // still reach the image diff viewer. |