blob: d705899f6c6d3b43adc3cf84b75399b25b197779 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import './patch-diff-links.css';
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import features from '.';
function init(): void {
let commitUrl = location.pathname.replace(/\/$/, '');
if (pageDetect.isPRCommit()) {
commitUrl = commitUrl.replace(/\/pull\/\d+\/commits/, '/commit');
}
select('.commit-meta > :last-child')!.append(
<span className="sha-block patch-diff-links">
<a href={`${commitUrl}.patch`} className="sha">patch</a>
{ ' ' /* Workaround for: JSX eats whitespace between elements */ }
<a href={`${commitUrl}.diff`} className="sha">diff</a>
</span>
);
}
void features.add(__filebasename, {
include: [
pageDetect.isCommit
],
exclude: [
pageDetect.isPRCommit404
],
init
});
|