diff options
author | 2020-05-19 07:51:07 -0400 | |
---|---|---|
committer | 2020-05-19 13:51:07 +0200 | |
commit | 508c93a3f4cf219f343d19b927ae0d07ec3ad7f8 (patch) | |
tree | acecf8f206413c0b1f7b7db3f4291489ba89788a /source/features/edit-files-faster.tsx | |
parent | db8f46bf74ffefbbc863f011085903a226f03129 (diff) | |
download | refined-github-508c93a3f4cf219f343d19b927ae0d07ec3ad7f8.tar.gz refined-github-508c93a3f4cf219f343d19b927ae0d07ec3ad7f8.tar.zst refined-github-508c93a3f4cf219f343d19b927ae0d07ec3ad7f8.zip |
Ensure features work on branches/tags with slashes (#3083)20.5.19
Diffstat (limited to 'source/features/edit-files-faster.tsx')
-rw-r--r-- | source/features/edit-files-faster.tsx | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/source/features/edit-files-faster.tsx b/source/features/edit-files-faster.tsx index c20bd10b..07bfb82d 100644 --- a/source/features/edit-files-faster.tsx +++ b/source/features/edit-files-faster.tsx @@ -6,21 +6,17 @@ import * as pageDetect from 'github-url-detection'; import {wrap} from '../libs/dom-utils'; import features from '../libs/features'; +import {parseRoute} from '../libs/utils'; import getDefaultBranch from '../libs/get-default-branch'; import onFileListUpdate from '../libs/on-file-list-update'; async function init(): Promise<void> { const defaultBranch = await getDefaultBranch(); + const isPermalink = /Tag|Tree/.test(select('.branch-select-menu i')!.textContent!); for (const fileIcon of select.all('.files :not(a) > .octicon-file')) { - const pathnameParts = fileIcon - .closest('tr')! - .querySelector<HTMLAnchorElement>('.js-navigation-open')! - .pathname - .split('/'); - - pathnameParts[3] = 'edit'; // Replaces `/blob/` - - const isPermalink = /Tag|Tree/.test(select('.branch-select-menu i')!.textContent!); + const {pathname} = fileIcon.closest('tr')!.querySelector<HTMLAnchorElement>('.js-navigation-open')!; + const pathnameParts = parseRoute(pathname); + pathnameParts[3] = 'edit'; // Replaces /blob/ if (isPermalink) { pathnameParts[4] = defaultBranch; // Replaces /${tag|commit}/ } |