Skip to content

Commit fdc95c2

Browse files
committed
fix: initCloneSchemeUrlSection fallback issues
Signed-off-by: Quentin Guidée <[email protected]>
1 parent b2061a8 commit fdc95c2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

web_src/js/features/repo-common.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,22 @@ function initCloneSchemeUrlSelection(parent: Element) {
5757
const tabSsh = parent.querySelector('.repo-clone-ssh');
5858
const tabTea = parent.querySelector('.repo-clone-tea');
5959
const updateClonePanelUi = function() {
60-
const scheme = localStorage.getItem('repo-clone-protocol') || 'https';
61-
const isHttps = scheme === 'https' && Boolean(tabHttps) || scheme !== 'https' && !tabHttps;
62-
const isSsh = scheme === 'ssh' && Boolean(tabSsh) || scheme !== 'ssh' && !tabSsh;
63-
const isTea = scheme === 'tea' && Boolean(tabTea) || scheme !== 'tea' && !tabTea;
60+
let scheme = localStorage.getItem('repo-clone-protocol') || 'https';
61+
62+
// Fallbacks if the scheme preference is not available in the tabs.
63+
if (scheme === 'tea' && !tabTea) {
64+
scheme = 'https';
65+
}
66+
if (scheme === 'https' && !tabHttps) {
67+
scheme = 'ssh';
68+
} else if (scheme === 'ssh' && !tabSsh) {
69+
scheme = 'https';
70+
}
71+
72+
const isHttps = scheme === 'https';
73+
const isSsh = scheme === 'ssh';
74+
const isTea = scheme === 'tea';
75+
6476
if (tabHttps) {
6577
tabHttps.textContent = window.origin.split(':')[0].toUpperCase(); // show "HTTP" or "HTTPS"
6678
tabHttps.classList.toggle('active', isHttps);

0 commit comments

Comments
 (0)