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 '../libs/features'; function init(): void { let commitUrl = location.pathname.replace(/\/$/, ''); if (pageDetect.isPRCommit()) { commitUrl = commitUrl.replace(/\/pull\/\d+\/commits/, '/commit'); } select('.commit-meta > :last-child')!.append( patch { ' ' /* Workaround for: JSX eats whitespace between elements */ } diff ); } features.add({ id: __filebasename, description: 'Adds links to `.patch` and `.diff` files in commits.', screenshot: 'https://cloud.githubusercontent.com/assets/737065/13605562/22faa79e-e516-11e5-80db-2da6aa7965ac.png' }, { include: [ pageDetect.isCommit ], init });