diff options
author | Abdul Monim <110587615+monim67-renforce@users.noreply.github.com> | 2022-09-20 20:01:24 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-20 22:01:24 +0800 |
commit | 54d4e664c2b78213f2e55e3ba972032f82898c83 (patch) | |
tree | bdec94a57bd9d962d7e23d5086e470833818c064 | |
parent | c571ac6fd3b6c0685c060613389e8ce094da31d5 (diff) | |
download | gitea-54d4e664c2b78213f2e55e3ba972032f82898c83.tar.gz gitea-54d4e664c2b78213f2e55e3ba972032f82898c83.zip |
Make the vscode clone link respect transport protocol (#20557) (#21128)
Backports #20557
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: Munim Munna <6266677+monim67@users.noreply.github.com>
-rw-r--r-- | templates/repo/clone_script.tmpl | 5 | ||||
-rw-r--r-- | templates/repo/home.tmpl | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl index 48b7ad3299..5c9a545cad 100644 --- a/templates/repo/clone_script.tmpl +++ b/templates/repo/clone_script.tmpl @@ -1,6 +1,8 @@ <script> // synchronously set clone button states and urls here to avoid flickering // on page load. initRepoCloneLink calls this when proto changes. + // this applies the protocol-dependant clone url to all elements with the + // `js-clone-url` and `js-clone-url-vsc` classes. // TODO: This localStorage setting should be moved to backend user config // so it's available during rendering, then this inline script can be removed. (window.updateCloneStates = function() { @@ -19,5 +21,8 @@ for (const el of document.getElementsByClassName('js-clone-url')) { el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link; } + for (const el of document.getElementsByClassName('js-clone-url-vsc')) { + el['href'] = `vscode://vscode.git/clone?url=${encodeURIComponent(link)}`; + } })(); </script> diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index a2f09e4b8a..2f9b1f25b7 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -126,7 +126,7 @@ <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> <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> {{end}} - <a class="item" href="vscode://vscode.git/clone?url={{$.RepoCloneLink.HTTPS}}">{{svg "gitea-vscode" 16 "mr-3"}}{{.i18n.Tr "repo.clone_in_vsc"}}</a> + <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> </div> </button> </div> |