Skip to content

Commit 54d4e66

Browse files
Abdul Monimnoerwmonim67
authored
Make the vscode clone link respect transport protocol (#20557) (#21128)
Backports #20557 Co-authored-by: Norwin <[email protected]> Co-authored-by: Munim Munna <[email protected]>
1 parent c571ac6 commit 54d4e66

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

templates/repo/clone_script.tmpl

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script>
22
// synchronously set clone button states and urls here to avoid flickering
33
// on page load. initRepoCloneLink calls this when proto changes.
4+
// this applies the protocol-dependant clone url to all elements with the
5+
// `js-clone-url` and `js-clone-url-vsc` classes.
46
// TODO: This localStorage setting should be moved to backend user config
57
// so it's available during rendering, then this inline script can be removed.
68
(window.updateCloneStates = function() {
@@ -19,5 +21,8 @@
1921
for (const el of document.getElementsByClassName('js-clone-url')) {
2022
el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link;
2123
}
24+
for (const el of document.getElementsByClassName('js-clone-url-vsc')) {
25+
el['href'] = `vscode://vscode.git/clone?url=${encodeURIComponent(link)}`;
26+
}
2227
})();
2328
</script>

templates/repo/home.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "mr-3"}}{{.i18n.Tr "repo.download_tar"}}</a>
127127
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "mr-3"}}{{.i18n.Tr "repo.download_bundle"}}</a>
128128
{{end}}
129-
<a class="item" href="vscode://vscode.git/clone?url={{$.RepoCloneLink.HTTPS}}">{{svg "gitea-vscode" 16 "mr-3"}}{{.i18n.Tr "repo.clone_in_vsc"}}</a>
129+
<a class="item js-clone-url-vsc" href="vscode://vscode.git/clone?url={{.CloneButtonOriginLink.HTTPS}}">{{svg "gitea-vscode" 16 "mr-3"}}{{.i18n.Tr "repo.clone_in_vsc"}}</a>
130130
</div>
131131
</button>
132132
</div>

0 commit comments

Comments
 (0)