diff options
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/pages/projects/blob/show/index.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/repository/index.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/repository/utils/ref_switcher_utils.js | 27 |
3 files changed, 16 insertions, 25 deletions
diff --git a/app/assets/javascripts/pages/projects/blob/show/index.js b/app/assets/javascripts/pages/projects/blob/show/index.js index 02fcc6ea940..a0f391c912b 100644 --- a/app/assets/javascripts/pages/projects/blob/show/index.js +++ b/app/assets/javascripts/pages/projects/blob/show/index.js @@ -15,7 +15,7 @@ import '~/sourcegraph/load'; import createStore from '~/code_navigation/store'; import { generateRefDestinationPath } from '~/repository/utils/ref_switcher_utils'; import RefSelector from '~/ref/components/ref_selector.vue'; -import { joinPaths, visitUrl } from '~/lib/utils/url_utility'; +import { visitUrl } from '~/lib/utils/url_utility'; Vue.use(Vuex); Vue.use(VueApollo); @@ -34,7 +34,7 @@ const initRefSwitcher = () => { if (!refSwitcherEl) return false; - const { projectId, projectRootPath, ref, refType } = refSwitcherEl.dataset; + const { projectId, projectRootPath, ref } = refSwitcherEl.dataset; return new Vue({ el: refSwitcherEl, @@ -42,8 +42,7 @@ const initRefSwitcher = () => { return createElement(RefSelector, { props: { projectId, - value: refType ? joinPaths('refs', refType, ref) : ref, - useSymbolicRefNames: true, + value: ref, }, on: { input(selectedRef) { diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js index 0db9dcb43df..6cedc606a37 100644 --- a/app/assets/javascripts/repository/index.js +++ b/app/assets/javascripts/repository/index.js @@ -2,7 +2,7 @@ import { GlButton } from '@gitlab/ui'; import Vue from 'vue'; import Vuex from 'vuex'; import { parseBoolean } from '~/lib/utils/common_utils'; -import { joinPaths, escapeFileUrl, visitUrl } from '~/lib/utils/url_utility'; +import { escapeFileUrl, visitUrl } from '~/lib/utils/url_utility'; import { __ } from '~/locale'; import initWebIdeLink from '~/pages/projects/shared/web_ide_link'; import PerformancePlugin from '~/performance/vue_performance_plugin'; @@ -128,7 +128,7 @@ export default function setupVueRepositoryList() { if (!refSwitcherEl) return false; - const { projectId, projectRootPath, refType } = refSwitcherEl.dataset; + const { projectId, projectRootPath } = refSwitcherEl.dataset; return new Vue({ el: refSwitcherEl, @@ -136,8 +136,7 @@ export default function setupVueRepositoryList() { return createElement(RefSelector, { props: { projectId, - value: refType ? joinPaths('refs', refType, ref) : ref, - useSymbolicRefNames: true, + value: ref, }, on: { input(selectedRef) { diff --git a/app/assets/javascripts/repository/utils/ref_switcher_utils.js b/app/assets/javascripts/repository/utils/ref_switcher_utils.js index bcad4a2c822..c62f7f709c4 100644 --- a/app/assets/javascripts/repository/utils/ref_switcher_utils.js +++ b/app/assets/javascripts/repository/utils/ref_switcher_utils.js @@ -16,29 +16,22 @@ const getNamespaceTargetRegex = (ref) => new RegExp(`(/-/(blob|tree))/${ref}/(.* * @param {string} selectedRef - The selected ref from the ref dropdown. */ export function generateRefDestinationPath(projectRootPath, ref, selectedRef) { - const url = new URL(window.location.href); - const currentPath = url.pathname; - let refType = null; + const currentPath = window.location.pathname; + const encodedHash = '%23'; let namespace = '/-/tree'; let target; - let actualRef = selectedRef; - - const matches = selectedRef.match(/^refs\/(heads|tags)\/(.+)/); - if (matches) { - [, refType, actualRef] = matches; - } - if (refType) { - url.searchParams.set('ref_type', refType); - } else { - url.searchParams.delete('ref_type'); - } - const NAMESPACE_TARGET_REGEX = getNamespaceTargetRegex(ref); const match = NAMESPACE_TARGET_REGEX.exec(currentPath); if (match) { [, namespace, , target] = match; } - url.pathname = joinPaths(projectRootPath, namespace, actualRef, target); - return url.toString(); + const destinationPath = joinPaths( + projectRootPath, + namespace, + encodeURI(selectedRef).replace(/#/g, encodedHash), + target, + ); + + return `${destinationPath}${window.location.hash}`; } |