message: Link to current file/folder in `forked-to` links
diff: @@ -11,6 +11,7 @@ import LinkExternalIcon from 'octicon/link-external.svg';
  import features from '.';
  import fetchDom from '../helpers/fetch-dom';
  +import GitHubURL from '../github-helpers/github-url';
  import {getRepoURL, getUsername, getForkedRepo} from '../github-helpers';
  const getForkSourceRepo = (): string => getForkedRepo() ?? getRepoURL();
  @@ -29,6 +30,21 @@ const updateCache = cache.function(async (): Promise<string[] | undefined> => {
  staleWhileRevalidate: 5
  });
  +function createLink(baseRepo: string): string {
  + if (pageDetect.isRepoRoot() || !(pageDetect.isSingleFile() || pageDetect.isRepoTree())) {
  + return '/' + baseRepo;
  + }
  +
  + const [user, repository] = baseRepo.split('/');
  + const url = new GitHubURL(location.href).assign({
  + user,
  + repository,
  + branch: 'HEAD'
  + });
  +
  + return url.pathname;
  +}
  +
  async function updateUI(forks: string[]): Promise<void> {
  // Don't add button if you're visiting the only fork available
  if (forks.length === 1 && forks[0] === getRepoURL()) {
  @@ -40,7 +56,7 @@ async function updateUI(forks: string[]): Promise<void> {
  if (forks.length === 1) {
  forkCounter.before(
  <a
  - href={`/${forks[0]}`}
  + href={createLink(forks[0])}
  className="btn btn-sm float-left rgh-forked-button"
  title={`Open your fork at ${forks[0]}`}
  >
  @@ -63,7 +79,7 @@ async function updateUI(forks: string[]): Promise<void> {
  </div>
  {forks.map(fork => (
  <a
  - href={`/${fork}`}
  + href={createLink(fork)}
  className={`select-menu-item ${fork === getRepoURL() ? 'selected' : ''}`}
  title={`Open your fork at ${fork}`}
  >
  