diff options
author | 2019-07-29 17:36:28 +0700 | |
---|---|---|
committer | 2019-07-29 17:36:28 +0700 | |
commit | a1a7442a724499167ceee80c171a498c96bbd813 (patch) | |
tree | cc12e28c915b9d19d8e60d94426618bedf57b42d /source/features/edit-files-faster.tsx | |
parent | b252f2bd9da516cea7666519f12baa99cb33d8e9 (diff) | |
download | refined-github-a1a7442a724499167ceee80c171a498c96bbd813.tar.gz refined-github-a1a7442a724499167ceee80c171a498c96bbd813.tar.zst refined-github-a1a7442a724499167ceee80c171a498c96bbd813.zip |
Fix `edit-files-faster` feature (#2279)
* Fix `edit-files-faster` feature
* Lint
Diffstat (limited to 'source/features/edit-files-faster.tsx')
-rw-r--r-- | source/features/edit-files-faster.tsx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/features/edit-files-faster.tsx b/source/features/edit-files-faster.tsx index e8487dcd..4c24792d 100644 --- a/source/features/edit-files-faster.tsx +++ b/source/features/edit-files-faster.tsx @@ -4,8 +4,10 @@ import select from 'select-dom'; import features from '../libs/features'; import * as icons from '../libs/icons'; import {wrap} from '../libs/dom-utils'; +import getDefaultBranch from '../libs/get-default-branch'; -function init(): void { +async function init(): Promise<void> { + const defaultBranch = await getDefaultBranch(); for (const fileIcon of select.all('.files :not(a) > .octicon-file')) { const pathnameParts = fileIcon .closest('tr')! @@ -15,6 +17,11 @@ function init(): void { pathnameParts[3] = 'edit'; // Replaces `/blob/` + const isPermalink = /Tag|Tree/.test(select('.branch-select-menu i')!.textContent!); + if (isPermalink) { + pathnameParts[4] = defaultBranch; // Replaces /${tag|commit}/ + } + wrap(fileIcon, <a href={pathnameParts.join('/')} className="rgh-edit-files-faster" />); fileIcon.after(icons.edit()); } |