blob: 79d2ce25090c440facefadafc1efc0a62d46f480 (
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
33
34
|
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import features from '.';
import {getCleanPathname} from '../github-helpers';
function init(): void {
let commitUrl = '/' + getCleanPathname();
// Avoids a redirection
if (pageDetect.isPRCommit()) {
commitUrl = commitUrl.replace(/\/pull\/\d+\/commits/, '/commit');
}
select('.commit-meta > :last-child')!.append(
<span className="sha-block">
<a data-skip-pjax href={`${commitUrl}.patch`} className="sha">patch</a>
{ ' ' /* Workaround for: JSX eats whitespace between elements */ }
<a data-skip-pjax href={`${commitUrl}.diff`} className="sha">diff</a>
</span>,
);
}
void features.add(import.meta.url, {
include: [
pageDetect.isCommit,
],
exclude: [
pageDetect.isPRCommit404,
],
deduplicate: 'has-rgh-inner',
init,
});
|